Displaying 1 result from an estimated 1 matches for "return_sql".
2008 Sep 17
13
Capturing the sql from a statement without executing it?
Hi guys,
Is there an elegant way to capture the sql that would have been
executed by an ActiveRecord statement, without actually executing
it? :)
I''m imagining something like
sql = User.find(1).groups.to_sql
or perhaps
sql = ActiveRecord::Base.capture_sql { User.find(1).groups }
resulting in sql = ''SELECT * FROM groups INNER JOIN memberships....
WHERE users.id =