Skip to content

Commit

Permalink
Fix unset_slug_if_invalid
Browse files Browse the repository at this point in the history
Fix if statement to run want the record is invalid.

Should fix norman#959
  • Loading branch information
maxime-carbonneau authored Nov 3, 2024
1 parent 40b899a commit 1ff3e3e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/friendly_id/slugged.rb
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def slug_generator
private :slug_generator

def unset_slug_if_invalid
if errors.key?(friendly_id_config.query_field) && attribute_changed?(friendly_id_config.query_field.to_s)
if errors.present? && attribute_changed?(friendly_id_config.query_field.to_s)
diff = changes[friendly_id_config.query_field]
send "#{friendly_id_config.slug_column}=", diff.first
end
Expand Down

0 comments on commit 1ff3e3e

Please sign in to comment.