Module: ActiveRecord::Extensions::FinderOptions::ClassMethods
- Defined in:
- lib/ar-extensions/finder_options.rb
Instance Method Summary collapse
-
#finder_sql_to_string(options) ⇒ Object
Return a string containing the SQL used with the find(:all) The options are the same as those with find(:all).
Instance Method Details
#finder_sql_to_string(options) ⇒ Object
Return a string containing the SQL used with the find(:all) The options are the same as those with find(:all)
Additional parameter of :force_eager_load
forces eager loading even if the
column is not referenced.
sql = Contact.finder_sql_to_string(:include => :primary_email_address)
Contact.find_by_sql(sql + 'USE_INDEX(blah)')
77 78 79 80 81 |
# File 'lib/ar-extensions/finder_options.rb', line 77 def finder_sql_to_string() select_sql = self.send( (use_eager_loading_sql?() ? :finder_sql_with_included_associations : :construct_finder_sql), .reject{|k,v| k == :force_eager_load}).strip end |