Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11562: patch_fix_dynamic_finders_on_associations_with_include_and_order.diff

File patch_fix_dynamic_finders_on_associations_with_include_and_order.diff, 2.0 kB (added by jes5199, 3 months ago)
  • activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb

    old new  
    8787                        :joins => @join_sql, 
    8888                        :readonly => false, 
    8989                        :order => @reflection.options[:order], 
     90                        :include => @reflection.options[:include], 
    9091                        :limit => @reflection.options[:limit] } } 
    9192        end 
    9293 
  • activerecord/lib/active_record/associations/has_many_association.rb

    old new  
    100100          create_scoping = {} 
    101101          set_belongs_to_association_for(create_scoping) 
    102102          { 
    103             :find => { :conditions => @finder_sql, :readonly => false, :order => @reflection.options[:order], :limit => @reflection.options[:limit] }, 
     103            :find => { :conditions => @finder_sql, :readonly => false, :order => @reflection.options[:order], :limit => @reflection.options[:limit], :include => @reflection.options[:include]}, 
    104104            :create => create_scoping 
    105105          } 
    106106        end 
  • activerecord/lib/active_record/associations.rb

    old new  
    14881488        end 
    14891489 
    14901490        def order_tables(options) 
    1491           order = options[:order] 
     1491          order = [options[:order], scope(:find, :order) ].join(", ") 
    14921492          return [] unless order && order.is_a?(String) 
    14931493          order.scan(/([\.\w]+).?\./).flatten 
    14941494        end 
    14951495