Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for UUID set on invalid object #1013

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

brian-davis
Copy link

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.

  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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant