Sha256: 899e69e28c3cff3f0f5a1dd270be24f45d3c594d3979599f17cea67465c1532f
Contents?: true
Size: 974 Bytes
Versions: 2
Compression:
Stored size: 974 Bytes
Contents
module GroupedScope module HasManyAssociation def self.included(klass) klass.class_eval do alias_method_chain :construct_sql, :group_scope end end def construct_sql_with_group_scope if @reflection.options[:grouped_scope] # CHANGED [Rails 1.2.6] Account for quoted_table_name. table_name = @reflection.respond_to?(:quoted_table_name) ? @reflection.quoted_table_name : @reflection.klass.table_name if @reflection.options[:as] # TODO: Need to add case for polymorphic :as option. else @finder_sql = "#{table_name}.#{@reflection.primary_key_name} IN (#{@owner.group.quoted_ids})" @finder_sql << " AND (#{conditions})" if conditions end @counter_sql = @finder_sql else construct_sql_without_group_scope end end end end ActiveRecord::Associations::HasManyAssociation.send :include, GroupedScope::HasManyAssociation
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
decisiv-grouped_scope-0.5.1.1 | lib/grouped_scope/has_many_association.rb |
metaskills-grouped_scope-0.5.1 | lib/grouped_scope/has_many_association.rb |