public
Description: Display the SQL of any given query
Homepage:
Clone URL: git://github.com/radar/sql_display.git
README.markdown

sql_display

For when you want to display the SQL a query executes, but don't want to go into the log!

Usage Examples

sql takes the same options as find and will only show you the first query it runs. count_sql takes the same options as count, same deal.

>> Post.sql
=> "SELECT * FROM \"posts\""

>> Post.sql(:order => "id DESC")
=> "SELECT * FROM \"posts\" ORDER id DESC"

>> Post.scoped({}).sql
=> "SELECT * FROM \"posts\""

>> Post.count_sql
=> "SELECT count(*) AS count_all FROM \"posts\""

>> Post.count_sql(:text)
=> "SELECT count(\"posts\".text) AS count_text FROM \"posts\""

Contributors

perplect