Whereas the verbose feature of SQL/ActiveRecord calls is useful most of the time, I would like to turn it off in cases where I have some looping going on.
Is there a way to turn it off?
irb(main):055:0> City.first ←[1m←[35mCity Load (1.0ms)←[0m SELECT `cities`.* FROM `cities` LIMIT 1 => #<City id: 1, name: "bla bla", state_id: 1, zip: nil, country_id: nil, created_at: "2011-03-27 14:11:28", updated_at: "2011-08-16 11:14:36", guid: "5PK fvvz2Gsi">
Active Record is the M in MVC - the model - which is the layer of the system responsible for representing business data and logic. Active Record facilitates the creation and use of business objects whose data requires persistent storage to a database.
One of the primary aspects of ActiveRecord is that there is very little to no configuration needed. It follow convention over configuration. ActiveRecord is commonly used with the Ruby-on-Rails framework but you can use it with Sinatra or without any web framework if desired.
ActiveRecord::Base indicates that the ActiveRecord class or module has a static inner class called Base that you're extending.
ActiveRecord is an ORM. It's a layer of Ruby code that runs between your database and your logic code. When you need to make changes to the database, you'll write Ruby code, and then run "migrations" which makes the actual changes to the database.
In console:
Disable:
old_logger = ActiveRecord::Base.logger ActiveRecord::Base.logger = nil
Enable:
ActiveRecord::Base.logger = old_logger
In Rails 4 I've been annoyed by ActiveRecord logging SQL statements in the middle of my specs so I disable it by adding this to config/environments/test.rb
:
Rails.application.configure do # ... config.log_level = :info end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With