lib/ransack/adapters/active_record/3.1/context.rb
# Redefine a few things for ActiveRecord 3.1.
Redefine a few things for ActiveRecord 3.1.
Redefine a few things for ActiveRecord 3 . 1 .
def build_or_find_association(name, parent = @base, klass = nil)
          found_association = @join_dependency.join_associations
          .detect do |assoc|
            assoc.reflection.name == name &&
            assoc.parent == parent &&
            (!klass || assoc.reflection.klass == klass)
          end
          unless found_association
            @join_dependency.send(
              :build, Polyamorous::Join.new(name, @join_type, klass), parent
              )
            found_association = @join_dependency.join_associations.last
            default_conditions = found_association.active_record.scoped.arel.constraints
            if default_conditions.any?
              and_default_conditions = "AND #{default_conditions.reduce(&:and).to_sql}"
            end
            @object = @object.joins(found_association).joins(and_default_conditions)
          end
          found_association
        end
def build_or_find_association ( name , parent = @base , klass = nil ) found_association = @join_dependency . join_associations . detect do | assoc | assoc . reflection . name == name && assoc . parent == parent && ( ! klass || assoc . reflection . klass == klass ) end unless found_association @join_dependency . send ( :build , Polyamorous :: Join . new ( name , @join_type , klass ) , parent ) found_association = @join_dependency . join_associations . last default_conditions = found_association . active_record . scoped . arel . constraints if default_conditions . any? and_default_conditions = "AND #{default_conditions.reduce(&:and).to_sql}" end @object = @object . joins ( found_association ) . joins ( and_default_conditions ) end found_association end
Redefine a few things for ActiveRecord 3.1.
Redefine a few things for ActiveRecord 3 . 1 .
# Leverage the stashed association functionality in AR
name
parent
klass