Reputation: 1282
I'm working on a project which requires talking to two different databases: a MySQL one for persistent data and an experimental in-memory database for real-time data.
It would make my life a bit easier if there was a way to access and use the SQL Query generated by the ActiveRecord finders.
I know there have been other questions along these lines but the answers they had seemed to suggest logging the SQL to STDOUT and were not for Rails 3
Upvotes: 3
Views: 3104
Reputation: 3236
Model.all
executes the query and you are trying to call to_sql
on an Array.
Do this
Model.scoped.to_sql
Upvotes: 5