lib/hanami/model/associations/belongs_to.rb in hanami-model-1.1.0.beta3 vs lib/hanami/model/associations/belongs_to.rb in hanami-model-1.1.0.rc1
- old
+ new
@@ -80,18 +80,25 @@
# Returns primary key and foreign key
#
# @since 1.1.0
# @api private
def association_keys
- relation(source)
- .associations[target]
+ association
.__send__(:join_key_map, container.relations)
end
+ # Return the ROM::Associations for the source relation
+ #
+ # @since 1.1.9
+ # @api private
+ def association
+ relation(source).associations[target]
+ end
+
# @since 1.1.0
# @api private
def _build_scope
- result = relation(target)
+ result = relation(association.target.to_sym)
result = result.where(foreign_key => subject.fetch(primary_key)) unless subject.nil?
result.as(Model::MappedRelation.mapper_name)
end
end
end