See this for a mini test:
While just looking at the test, it doesn't seem like you'd see this very often, but if you
AR .persisted? throws SystemStackError for an unsaved model with a
custom primary_key that didn't save due to validation error
Thanks you very much for your contribution! I've noted that you are creating a new model but we try to avoid it as much as possible since they are still numerous. It looks like you could just use the Movie model and add a validation on its name field. What do you think ?
Could you also please add a changelog entry to describe the change you've made ?
This is sometimes tricky to find a model that fits with your test case but you can use the grep command. For instance:
$ grep -Rn "self.primary_key" activerecord/test/models
refactor fix for #14393 and add CHANGELOG
The CHANGELOG must be placed on top of the file.
Fixed error where `.persisted?` throws `SystemStackError` for an unsaved model with a
Also please squash your commits.
custom primary key that didn't save due to validation error.
Better to tell more about the problem in the test description. Something like: test_persisted_in_a_model_with_custom_primary_key_after_failed_save
Very good patch. I made some comments in the code.
Merge pull request #14456 from henrik/add-validate-method
ActiveRecord/ActiveModel '#validate' alias for 'valid?'
Add CHANGELOG to Active Model too [ci skip]
Merge branch 'persisted_exception' of github.com:chrisfinne/rails int…
refactor fix for #14393
I fixed the CHANGELOG placement and syntax and renamed the test method as requested.
I tried squashing the commits but kept running into merge problems, so it looks like a mess. Should I just redo everything under a different pull request?
I can do it for you if you want.
If that's easiest, thanks.
Thank you so much