class Ransack::Adapters::ActiveRecord::Context

def build_association(name, parent = @base, klass = nil)

def build_association(name, parent = @base, klass = nil)
  jd = Polyamorous::JoinDependency.new(
    parent.base_klass,
    parent.table,
    Polyamorous::Join.new(name, @join_type, klass),
    @join_type
  )
  found_association = jd.instance_variable_get(:@join_root).children.last
  @associations_pot[found_association] = parent
  # TODO maybe we dont need to push associations here, we could loop
  # through the @associations_pot instead
  @join_dependency.instance_variable_get(:@join_root).children.push found_association
  # Builds the arel nodes properly for this association
  @tables_pot[found_association] = @join_dependency.construct_tables_for_association!(jd.instance_variable_get(:@join_root), found_association)
  # Leverage the stashed association functionality in AR
  @object = @object.joins(jd)
  found_association
end