Last Updated: February 25, 2016
·
1.287K
· deteam

Rails2 to_sql

Needed to have sql query generated with a multiply-scoped model with some custom conditions at the end.

Here's the link

https://makandracards.com/makandra/1144-retrieve-the-sql-query-a-scope-would-produce-in-activerecord

Example:

query = MyModel.scope1.scope2(an_option).scoped(:conditions => "...").send(:construct_finder_sql, {})

1 Response
Add your response

Awesome, thanks.

over 1 year ago ·