Warning: strip_tags() expects parameter 1 to be string, array given in /var/www/php_apps/pedropimentel.com/wp-includes/formatting.php on line 631
Don’t you think it’s really irritating when, in the console, you are testing your model’s methods and everytime you need to check how each SQL query was formed you need to go to another tab to visualize the log ???
Your frustation is over. Just add the following lines in your .irbrc file:
def log_to ActiveRecord::Base.logger = Logger.new($stdout) ActiveRecord::Base.connection_pool.clear_reloadable_connections! end
You can change the method’s name to whatever suits your needs. After that, every time you are in your application’s console you just type log_to and you’re ready to go:
>> log_to =>  >> MyModel.count SQL (1.8ms) SELECT count(*) as count_all FROM "mymodels" => 10
This hint I got it from Pratik Naik while doing pair programming with him at the company I work.
Probably Related posts: