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

url should not be updated if model fails validation? #25

Closed
zapnap opened this issue Apr 30, 2011 · 3 comments
Closed

url should not be updated if model fails validation? #25

zapnap opened this issue Apr 30, 2011 · 3 comments

Comments

@zapnap
Copy link
Contributor

zapnap commented Apr 30, 2011

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

@zapnap
Copy link
Contributor Author

zapnap commented May 1, 2011

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!

@rsl
Copy link
Owner

rsl commented Aug 19, 2011

pulled this into master. i think. lemme know if i screwed it up. didn't close ticket [stupid me].

@rsl rsl closed this as completed Aug 19, 2011
@zapnap
Copy link
Contributor Author

zapnap commented Aug 20, 2011

Thanks!

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

No branches or pull requests

2 participants