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

Ticket #11506: duplicate_method_missing_for_has_many_through.diff

File duplicate_method_missing_for_has_many_through.diff, 1.2 kB (added by methodmissing, 6 months ago)

Diff with enhancement

  • lib/active_record/associations/has_many_through_association.rb

    old new  
    132132      end 
    133133 
    134134      protected 
    135         def method_missing(method, *args) 
    136           if @target.respond_to?(method) || (!@reflection.klass.respond_to?(method) && Class.respond_to?(method)) 
    137             if block_given? 
    138               super { |*block_args| yield(*block_args) } 
    139             else 
    140               super 
    141             end 
    142           elsif @reflection.klass.scopes.include?(method) 
    143             @reflection.klass.scopes[method].call(self, *args) 
    144           else 
    145             with_scope construct_scope do 
    146               if block_given? 
    147                 @reflection.klass.send(method, *args) { |*block_args| yield(*block_args) } 
    148               else 
    149                 @reflection.klass.send(method, *args) 
    150               end 
    151             end 
    152           end 
    153         end 
    154  
    155135        def find_target 
    156136          @reflection.klass.find(:all, 
    157137            :select     => construct_select,