radar / sql_display

Display the SQL of any given query

This URL has Read+Write access

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 your_models"

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

>> 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