Skip to content

Commit

Permalink
CV2-6141: update options in case existing model is blank
Browse files Browse the repository at this point in the history
  • Loading branch information
melsawy committed Feb 25, 2025
1 parent ca829cd commit 2274247
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/models/relationship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ def create_or_update_parent_id
def self.create_unless_exists(source_id, target_id, relationship_type, options = {})
# Verify that the target is not part of another source; in this case, we should return the existing relationship.
r = Relationship.where(target_id: target_id).where.not(source_id: source_id).last
# should update options if exists
unless r.nil? || !options.blank?
# should update options if exists and at least on field is blank
if !r.nil? && !options.blank? && r.model.blank?
options.each do |key, value|
r.send("#{key}=", value) if r.respond_to?("#{key}=")
end
Expand Down

0 comments on commit 2274247

Please sign in to comment.