lib/hanami/model/associations/many_to_many.rb in hanami-model-1.1.0.beta1 vs lib/hanami/model/associations/many_to_many.rb in hanami-model-1.1.0.beta2
- old
+ new
@@ -88,13 +88,14 @@
# rubocop:disable Metrics/AbcSize
def remove(target_id)
association_record = relation(through)
.where(target_foreign_key => target_id, source_foreign_key => subject.fetch(source_primary_key))
.one
- if association_record
- ar_id = association_record.public_send relation(through).primary_key
- command(:delete, relation(through)).by_pk(ar_id).call
- end
+
+ return if association_record.nil?
+
+ ar_id = association_record.public_send relation(through).primary_key
+ command(:delete, relation(through)).by_pk(ar_id).call
end
# rubocop:enable Metrics/AbcSize
private