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, {})
Written by DeTeam
Related protips
1 Response
Awesome, thanks.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Related Tags
#rails
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#