简体   繁体   中英

How I can see all the queries executed and classes or methods in my gemfile?

I´m newbie in RoR and I would like to know how I can do two things in Rails (both versions 2 and 3):

  1. How I can see all queries generated to database (save, update, find, etc.) in the console of the server?

  2. How I can see all the classes and methods of gems included in my Gemfile?

    For example how I can see classes and methods of CanCan, Devise and so on.

     gem "devise" gem "cancan" gem "rolify" gem "sass-rails" 

And so on...

Sorry for my english and thank in advance!!

In your rails folder there will be a log sub-folder. Depending on where your application is running and on your configurations you'll be able to see something similar to a development.log, staging.log or production.log file in that folder.

Also the .to_sql method can be used to show the sql. eg

User.where(:id => 29).to_sql will yield the following:

"SELECT `users`.* FROM `users` WHERE `users`.`id` = 29"

For viewing gems. In terminal type bundle show devise this will return you a path. Go to that path. All the necessary code will be present over there.

/home/sohaib/.rvm/gems/ree-1.8.7-2011.03@moviepass/gems/devise-1.4.9

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM