lib/hanami/model/associations/many_to_many.rb in hanami-model-1.1.0.beta3 vs lib/hanami/model/associations/many_to_many.rb in hanami-model-1.1.0.rc1

- old
+ new

@@ -156,14 +156,23 @@ # @api private def target_primary_key association_keys[1].last end + # Return the ROM::Associations for the source relation + # # @since 1.1.0 # @api private + def association + relation(source).associations[target] + end + + # @since 1.1.0 + # + # @api private # rubocop:disable Metrics/AbcSize def _build_scope - result = relation(target).qualified + result = relation(association.target.to_sym).qualified unless subject.nil? result = result .join(through, target_foreign_key => target_primary_key) .where(source_foreign_key => subject.fetch(source_primary_key)) end