Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Simple belongs_to && variants optimization

#169

Chris,

We're using these monkey patches in pre-production ... almost 0 overhead with regards to model changes and works well alongside non cached Models .... thoughts ?


module ActiveRecord
  module Associations
    class BelongsToAssociation
 
      private
        def find_target
          @reflection.klass.send( (@reflection.klass.respond_to?( :get_cache ) ? :get_cache : :find ),
            @owner[@reflection.primary_key_name], 
            :conditions => conditions,
            :include    => @reflection.options[:include]
          )
        end 
         
    end
  end
end      

module ActiveRecord
  module Associations
    class BelongsToPolymorphicAssociation
      
      private
      def find_target
        return nil if association_class.nil?
        _find_by_method = (association_class.respond_to?( :get_cache ) ? :get_cache : :find )   
        if @reflection.options[:conditions]
          association_class.send( _find_by_method,
            @owner[@reflection.primary_key_name], 
            :conditions => conditions,
            :include    => @reflection.options[:include]
          )
        else
          association_class.send( _find_by_method, @owner[@reflection.primary_key_name], :include => @reflection.options[:include])
        end
      end  
    end    
  end
end  

  • Lourens

Reported by Lourens Naude · December 4th, 2007 @ 01:24 AM

State: open
Milestone: none
Assigned to: Chris Wanstrath Chris Wanstrath

Activity

  1. Chris Wanstrath
    Chris Wanstrath
    • State changed from new to open

    December 4th, 2007 @ 12:11 PM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.