lib/ransack/adapters/active_record/3.1/context.rb
def build_join_dependency(relation)
          buckets = relation.joins_values.group_by do |join|
            case join
            when String
              Constants::STRING_JOIN
            when Hash, Symbol, Array
              Constants::ASSOCIATION_JOIN
            when JoinDependency::JoinAssociation
              Constants::STASHED_JOIN
            when Arel::Nodes::Join
              Constants::JOIN_NODE
            else
              raise 'unknown class: %s' % join.class.name
            end
          end

          association_joins = buckets[Constants::ASSOCIATION_JOIN] || []

          stashed_association_joins = buckets[Constants::STASHED_JOIN] || []

          join_nodes = buckets[Constants::JOIN_NODE] || []

          string_joins = (buckets[Constants::STRING_JOIN] || []).map(&:strip).uniq

          join_list = relation.send :custom_join_ast,
            relation.table.from(relation.table), string_joins

          join_dependency = JoinDependency.new(
            relation.klass,
            association_joins,
            join_list
          )

          join_nodes.each do |join|
            join_dependency.alias_tracker.aliases[join.left.name.downcase] = 1
          end

          join_dependency.graft(*stashed_association_joins)
        end
# 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_join_dependency(relation)
          buckets = relation.joins_values.group_by do |join|
            case join
            when String
              Constants::STRING_JOIN
            when Hash, Symbol, Array
              Constants::ASSOCIATION_JOIN
            when JoinDependency::JoinAssociation
              Constants::STASHED_JOIN
            when Arel::Nodes::Join
              Constants::JOIN_NODE
            else
              raise 'unknown class: %s' % join.class.name
            end
          end
          association_joins = buckets[Constants::ASSOCIATION_JOIN] || []
          stashed_association_joins = buckets[Constants::STASHED_JOIN] || []
          join_nodes = buckets[Constants::JOIN_NODE] || []
          string_joins = (buckets[Constants::STRING_JOIN] || []).map(&:strip).uniq
          join_list = relation.send :custom_join_ast,
            relation.table.from(relation.table), string_joins
          join_dependency = JoinDependency.new(
            relation.klass,
            association_joins,
            join_list
          )
          join_nodes.each do |join|
            join_dependency.alias_tracker.aliases[join.left.name.downcase] = 1
          end
          join_dependency.graft(*stashed_association_joins)
        end
def build_join_dependency ( relation ) buckets = relation . joins_values . group_by do | join | case join when String Constants :: STRING_JOIN when Hash , Symbol , Array Constants :: ASSOCIATION_JOIN when JoinDependency :: JoinAssociation Constants :: STASHED_JOIN when Arel :: Nodes :: Join Constants :: JOIN_NODE else raise 'unknown class: %s' % join . class . name end end association_joins = buckets [ Constants :: ASSOCIATION_JOIN ] || [ ] stashed_association_joins = buckets [ Constants :: STASHED_JOIN ] || [ ] join_nodes = buckets [ Constants :: JOIN_NODE ] || [ ] string_joins = ( buckets [ Constants :: STRING_JOIN ] || [ ] ) . map ( & :strip ) . uniq join_list = relation . send :custom_join_ast , relation . table . from ( relation . table ) , string_joins join_dependency = JoinDependency . new ( relation . klass , association_joins , join_list ) join_nodes . each do | join | join_dependency . alias_tracker . aliases [ join . left . name . downcase ] = 1 end join_dependency . graft ( * stashed_association_joins ) end
Redefine a few things for ActiveRecord 3.1.
Redefine a few things for ActiveRecord 3 . 1 .
relation