instance method
construct_join_attributes
Ruby on Rails 3.0.20
Since v3.0.20 Last seen in v3.0.20Signature
construct_join_attributes(associate)
Construct attributes for :through pointing to owner and associate.
Parameters
-
associatereq
Source
# File activerecord/lib/active_record/associations/through_association_scope.rb, line 100
def construct_join_attributes(associate)
# TODO: revisit this to allow it for deletion, supposing dependent option is supported
raise ActiveRecord::HasManyThroughCantAssociateThroughHasOneOrManyReflection.new(@owner, @reflection) if [:has_one, :has_many].include?(@reflection.source_reflection.macro)
join_attributes = construct_owner_attributes(@reflection.through_reflection).merge(@reflection.source_reflection.primary_key_name => associate.id)
if @reflection.options[:source_type]
join_attributes.merge!(@reflection.source_reflection.options[:foreign_type] => associate.class.base_class.name.to_s)
end
if @reflection.through_reflection.options[:conditions].is_a?(Hash)
join_attributes.merge!(@reflection.through_reflection.options[:conditions])
end
join_attributes
end
Defined in activerecord/lib/active_record/associations/through_association_scope.rb line 100
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Associations::ThroughAssociationScope