I am using a simple query in ActiveRecord which does something like this.
MyTable.find(:all, :conditions => {:start_date => format_time(params[:date]) })
I want to get the equivalent query that is executed in the background, perhaps using a puts
statement or something similar to that. MySQL is my database.
You can see the SQL query that is executed by viewing the development log located in log/development.log
. Note that the script/server
command tails this log file by default.
In Rails 3 you can append a .to_sql
method call to the end of the finder to output the SQL.
Alternatively, New Relic's free RPM Lite gem lets you see the SQL queries in developer mode as well as lots of other useful performance tuning information.
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