Wednesday, October 14, 2009

Script Console Tricks

Script console in rails helps me very much to debug my applications. However, I usually encounter an annoying problem with ActiveRecord. I want to see the generated SQL that has been executed. I never have enough time to figure out this until last week. Just add the following code to your environment.rb, you could see the generated SQL statement.


if "irb" == $0
ActiveRecord::Base.logger = Logger.new(STDOUT) # ActiveRecord
ActiveResource::Base.logger = Logger.new(STDOUT) # ActiveResource
end


For more information:
http://weblog.jamisbuck.org/2007/1/31/more-on-watching-activerecord
http://railscasts.com/episodes/48-console-tricks

5 comments:

Anonymous said...

It was rather interesting for me to read this article. Thank author for it. I like such topics and everything connected to this matter. I definitely want to read a bit more soon.

chamnap said...

Thanks for reading

Webplore said...

Good tips ,its very much useful and helpful tips....
Web Development

Webplore said...

Good tips ,its very much useful and helpful tips....
Web Development

Web Design Company Dubai said...

I read your blog very impressed seen this kind of important information’s. Really am interested to back to your blog again to gather some more information’s

http://www.infoquestit.com

Subscribe in a Reader