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
Use case: I have a model whose title is used to create the url / permalink. I'm using sync_url => true. update_attributes is called with a title value that fails validation (blank value when presence is required, for example).
When this happens, my Rails application re-renders the template with errors so the user can fix the validation problems. However, the url value has changed. Now, route shortcuts are broken because the model instance has an empty url, when the url probably never should have been updated at all.
I created a failing test to demonstrate the scenario. Can work on a patch if this makes sense (note that an after_validation callback won't fire if validation fails):
I added a possible solution for this issue in my branch this morning; will send a pull request. If you have a more elegant way to resolve it please let me know. Thanks!
Use case: I have a model whose title is used to create the url / permalink. I'm using sync_url => true. update_attributes is called with a title value that fails validation (blank value when presence is required, for example).
When this happens, my Rails application re-renders the template with errors so the user can fix the validation problems. However, the url value has changed. Now, route shortcuts are broken because the model instance has an empty url, when the url probably never should have been updated at all.
I created a failing test to demonstrate the scenario. Can work on a patch if this makes sense (note that an after_validation callback won't fire if validation fails):
zapnap@00ada38
The text was updated successfully, but these errors were encountered: