You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to generate the the slug with the name column and the id. So i set the slug_candidates like this:
defslug_candidates[[:name,:id]]end
The problem here is that the slug is set before the record is created. So when the slug is created the id is not yet set. I created an after_create custom method to unset the slug and then save again to regenerate the slug.
after_create:custom_set_slugdefcustom_set_slug# skips validations on pourpose, so when is called the save method it sets the proper slugupdate_column(:slug,nil)save!end
Is there a better way to do this?
The text was updated successfully, but these errors were encountered:
I want to generate the the
slug
with thename
column and theid
. So i set theslug_candidates
like this:The problem here is that the
slug
is set before the record is created. So when theslug
is created theid
is not yet set. I created anafter_create
custom method to unset the slug and then save again to regenerate the slug.Is there a better way to do this?
The text was updated successfully, but these errors were encountered: