FriendlyId is the “Swiss Army bulldozer” of slugging and permalink plugins for ActiveRecord. It allows you to create pretty URL’s and work with human-friendly strings as if they were numeric ids for ActiveRecord models.
Bug:
When using :should_generate_new_friendly_id? to enable slug update functionality,
on a model which has option friendly_id :title, use: :slugged, and an existing
validates :title, presence: true, the UUID is being set as the slug while the
object is in an invalid state. In a rails app, this will be set as the action
attribute in a form_with form, causing errors.
Fix:
Add an errors.key?(friendly_id_config.base) guard clause to :unset_slug_if_invalid
callback method.
Bug: When using
:should_generate_new_friendly_id?
to enable slug update functionality, on a model which has optionfriendly_id :title, use: :slugged
, and an existingvalidates :title, presence: true
, the UUID is being set as the slug while the object is in an invalid state. In a rails app, this will be set as the action attribute in aform_with
form, causing errors.Fix: Add an
errors.key?(friendly_id_config.base)
guard clause to:unset_slug_if_invalid
callback method.