-
Notifications
You must be signed in to change notification settings - Fork 901
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
Raise exception when Version creation fails? (Version.create vs Version.create!) #207
Comments
@JamesCropcho - Can you explain the scenario that you have where version creation is failing? I assume that you must have put custom validator(s) on your If you think that this is something that you would find useful, then by all means, a pull request is welcome (especially if it contains tests!). I'm wondering if we might be able to do an implementation where It appears as though a call to |
@fullbridge-batkins yes, version creation can fail when there are validations on Version, and when the table schema does not allow certain values to be NULL. Thanks for the sleuthing on #save! versus #create. In my case, I'm adding, for example, and IP address column, which I would in fact always expect to be present. Anyway, I have found a decent workaround. Here is my Version class:
This seems to do the trick, manually raising a RecordInvalid exception when the validation process detects errors. But by all means, if you (or anyone else) sees an issue with this implementation, let me know. I'm no longer inclined to make a pull request, as this appears to work well. Free free to weigh in otherwise. |
Thanks for reporting back. I think this seems like the best solution for the time being, but I think I'll try to revisit this concept at some point, perhaps for the |
Happy to help! |
this is related to #231 |
@brodock - how do you figure? |
Hello,
I have a
versions
table with additional custom fields, via #info_for_paper_trail.Ideally for me, an exception would be raised if the Version record is invalid (for example, due to a custom attribute missing). However, Version creation fails silently.
My question/offer: would it be generally useful (i.e. for people other than me) to have the exception raised, or to have a configuration parameter available which would do so optionally?
If so, I will be happy to provide a pull request with tests. And if not, I'd be curious to hear the rationale behind the silent failures.
By the way, Paper Trail's been great to me! Thank you very much, all contributors,
The text was updated successfully, but these errors were encountered: