Class: ActiveRecord::Associations::HasManyThroughAssociation
- Inherits:
-
HasManyAssociation
- Object
- AssociationCollection
- HasManyAssociation
- ActiveRecord::Associations::HasManyThroughAssociation
- Defined in:
- lib/composite_primary_keys/associations.rb
Overview
:nodoc:
Instance Method Summary collapse
- #construct_conditions_with_composite_keys ⇒ Object
- #construct_joins_with_composite_keys(custom_joins = nil) ⇒ Object
Methods inherited from HasManyAssociation
#construct_sql, #delete_records
Instance Method Details
#construct_conditions_with_composite_keys ⇒ Object
397 398 399 400 401 402 403 404 405 |
# File 'lib/composite_primary_keys/associations.rb', line 397 def construct_conditions_with_composite_keys if @reflection.through_reflection.[:as] construct_conditions_without_composite_keys else conditions = full_columns_equals(@reflection.through_reflection.table_name, @reflection.through_reflection.primary_key_name, @owner.quoted_id) conditions << " AND (#{sql_conditions})" if sql_conditions conditions end end |
#construct_joins_with_composite_keys(custom_joins = nil) ⇒ Object
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 |
# File 'lib/composite_primary_keys/associations.rb', line 408 def construct_joins_with_composite_keys(custom_joins = nil) if @reflection.through_reflection.[:as] || @reflection.source_reflection.[:as] construct_joins_without_composite_keys(custom_joins) else if @reflection.source_reflection.macro == :belongs_to reflection_primary_key = @reflection.klass.primary_key source_primary_key = @reflection.source_reflection.primary_key_name else reflection_primary_key = @reflection.source_reflection.primary_key_name source_primary_key = @reflection.klass.primary_key end "INNER JOIN %s ON %s #{@reflection.[:joins]} #{custom_joins}" % [ @reflection.through_reflection.quoted_table_name, composite_join_clause(full_keys(@reflection.table_name, reflection_primary_key), full_keys(@reflection.through_reflection.table_name, source_primary_key)) ] end end |