def construct_nested_join_attributes(reflection = @reflection, association_class = reflection.klass,
                                          table_ids = {association_class.table_name => 1})
      if reflection.macro == :has_many && reflection.through_reflection
        construct_has_many_through_attributes(reflection, table_ids)
      else
        construct_has_many_or_belongs_to_attributes(reflection, association_class, table_ids)
      end
    end
def construct_nested_join_attributes(reflection = @reflection, association_class = reflection.klass,
                                          table_ids = {association_class.table_name => 1})
      if reflection.macro == :has_many && reflection.through_reflection
        construct_has_many_through_attributes(reflection, table_ids)
      else
        construct_has_many_or_belongs_to_attributes(reflection, association_class, table_ids)
      end
    end
Given any belongs_to or has_many (including has_many :through) association,
 return the essential components of a join corresponding to that association, namely:

 * <tt>:joins</tt>: any additional joins required to get from the association's table
   (reflection.table_name) to the table that's actually joining to the active record's table
 * <tt>:remote_key</tt>: the name of the key in the join table (qualified by table name) which will join
   to a field of the active record's table
 * <tt>:local_key</tt>: the name of the key in the local table (not qualified by table name) which will
   take part in the join
 * <tt>:conditions</tt>: any additional conditions (e.g. filtering by type for a polymorphic association,
    or a :conditions clause explicitly given in the association), including a leading AND