Read more

ActiveType 1.2 supports "change_association"

Tobias Kraze
June 25, 2019Software engineer at makandra GmbH

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

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

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.

Posted by Tobias Kraze to makandra dev (2019-06-25 15:02)