Rails 3 ActiveRecord::Persistence#becomes does not copy changed attributes

Posted . Visible to the public.

Note: ActiveRecord::Base#becomes has a lot of quirks and inconsistent behavior. You probably want to use ActiveType.cast instead.


This issue will be encountered when relying on attribute_was methods of ActiveModel::Dirty after casting a model which has defaults to a form model, for example.

In my case a record with an assignable_values Show archive.org snapshot legacy value became invalid when it should not.

The initializer in the attached file will fix this issue.

This patch is planned to be included in the next makandra Rails LTS Show archive.org snapshot release.

Martin Straub
Last edit
Henning Koch
License
Source code in this card is licensed under the MIT License.
Posted by Martin Straub to makandra dev (2015-06-08 09:38)