Wednesday, August 18, 2010

[Rails] Re: rails3 console : how to get actual sql statements

Here there is a tip:

http://rubyquicktips.tumblr.com/post/292826666/display-activerecord-generated-sql-queries-in-the

In order to make it work for both Rails 2 and Rails 3, my ~/irbrc looks
like:

require 'logger'
if ENV.include?('RAILS_ENV')&&
!Object.const_defined?('RAILS_DEFAULT_LOGGER')
Object.const_set('RAILS_DEFAULT_LOGGER', Logger.new(STDOUT))
else
ActiveRecord::Base.logger = Logger.new(STDOUT)
end

...not sure though if there is a better way to do that... bye.
--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate