ActiveType 1.2 supports "change_association"

Updated . Posted . Visible to the public. Repeats.

With ActiveType Show archive.org snapshot 1.2 you can modify associations (has_many etc.) after they have been defined.

One common use case for this is to change an association inside a form model, like this:

class Credential < ActiveRecord::Base
end

class User < ActiveRecord::Base
  has_many :credentials
end

class SignUpCredential < ActiveType::Record[Credential]
end

class SignUp < ActiveType::Record[User]
  change_association :credentials, class_name: 'SignUpCredential'
end

Now, if you load credentials, you will automatically receive records of type SignUpCredential.

Tobias Kraze
Last edit
Jakob Scholz
License
Source code in this card is licensed under the MIT License.
Posted by Tobias Kraze to makandra dev (2019-06-25 13:02)