Retrieve SQL query in Rails 2.x

Posted . Visible to the public.

The method is construct_finder_sql(options) (lib/active_record/base.rb:1681) you will have to use send because it is private.

sql = Item.send :construct_finder_sql, :select => :all, :include => [:categories, :prices], :conditions => conditions

sql = ActionType.send :construct_finder_sql, :select => 'hosted, top_action_type, count(*) as count', :group => 'hosted, top_action_type'
Sandheep
Posted by Sandheep to Sandheep's deck (2016-03-10 14:27)