Sha256: 746329d8e2fa9babd41320f16121083ee72f9399410f3927278e8da18b928fa2
Contents?: true
Size: 859 Bytes
Versions: 5
Compression:
Stored size: 859 Bytes
Contents
module GroupedScope module HasManyThroughAssociation def self.included(klass) klass.class_eval do alias_method_chain :construct_conditions, :group_scope end end def construct_conditions_with_group_scope conditions = construct_conditions_without_group_scope if @reflection.options[:grouped_scope] if as = @reflection.options[:as] # TODO: Need to add case for polymorphic :as option. else pattern = "#{@reflection.primary_key_name} = #{@owner.quoted_id}" replacement = "#{@reflection.primary_key_name} IN (#{@owner.group.quoted_ids})" conditions.sub!(pattern,replacement) end end conditions end end end ActiveRecord::Associations::HasManyThroughAssociation.send :include, GroupedScope::HasManyThroughAssociation
Version data entries
5 entries across 5 versions & 3 rubygems