Class: Millstone::ActiveRecord::Associations::HasManyThroughWithoutDeletedAssociation

Inherits:
ActiveRecord::Associations::HasManyThroughAssociation
  • Object
show all
Defined in:
lib/millstone/active_record/associations/has_many_through_without_deleted_association.rb

Instance Method Summary collapse

Instance Method Details

#construct_conditionsObject



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/millstone/active_record/associations/has_many_through_without_deleted_association.rb', line 5

def construct_conditions
  return super unless @reflection.through_reflection.klass.as_millstone?

  table_name = @reflection.through_reflection.quoted_table_name
  conditions = construct_quoted_owner_attributes(@reflection.through_reflection).map do |attr, value|
    "#{table_name}.#{attr} = #{value}"
  end
  conditions << @reflection.through_reflection.klass.millstone_without_deleted_conditions
  conditions << sql_conditions if sql_conditions
  "(" + conditions.join(') AND (') + ")"
end