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
ActiveRecord::Persistence#becomes doesn't handle virtual attributes #41195
Comments
This issue has been automatically marked as stale because it has not been commented on for at least three months. |
not stale |
When source and target classes have a different set of attributes adapts attributes such that the extra attributes from target are added. Fixes rails#41195 Co-authored-by: SampsonCrowley <sampsonsprojects@gmail.com> Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
Steps to reproduce
Add a virtual attribute to an inherited model, and use
#becomes
from either the parent to the child or the child to the parentExpected behavior
Virtual Attributes should be correctly initialized and there shouldn't be any errors, since they have nothing to do with the database
Actual behavior
an
ActiveRecord::UnknownAttributeError
is thrown if you try to go either directionSystem configuration
Rails version: 6.0.3.4 (but I was the one who submitted the last patch for becomes to correctly move items back into the initialize block like they're supposed to be, so I have the current monkey patch for the latest version, it happens on all versions at least from 6+, tested up to 6.1.1)
Ruby version: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux] (but also really not a cause here)
The text was updated successfully, but these errors were encountered: