diff --git a/lib/friendly_id/slugged.rb b/lib/friendly_id/slugged.rb index 8e8fae23..6024f98f 100644 --- a/lib/friendly_id/slugged.rb +++ b/lib/friendly_id/slugged.rb @@ -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