makandra/active_type — pull request #1 by marcbey (2014-07-09 21:18:27+00:00)
Title: Fix an issue with uninitialized instance variables

Using a class like PostSignUp < ActiveType[Post] crashes on calling @post.update(post_params) with

active_type (0.1.2) lib/active_type/virtual_attributes.rb:135:in `write_virtual_attribute'
active_type (0.1.2) lib/active_type/virtual_attributes.rb:77:in `name='
activerecord (4.1.0) lib/active_record/attribute_assignment.rb:45:in `public_send'
activerecord (4.1.0) lib/active_record/attribute_assignment.rb:45:in `_assign_attribute'
activerecord (4.1.0) lib/active_record/attribute_assignment.rb:32:in `block in assign_attributes'
activerecord (4.1.0) lib/active_record/attribute_assignment.rb:26:in `each'
activerecord (4.1.0) lib/active_record/attribute_assignment.rb:26:in `assign_attributes'
activerecord (4.1.0) lib/active_record/persistence.rb:231:in `block in update'
activerecord (4.1.0) lib/active_record/transactions.rb:329:in `block in with_transaction_returning_status'
activerecord (4.1.0) lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `block in transaction'
activerecord (4.1.0) lib/active_record/connection_adapters/abstract/database_statements.rb:219:in `within_new_transaction'
activerecord (4.1.0) lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `transaction'
activerecord (4.1.0) lib/active_record/transactions.rb:208:in `transaction'
activerecord (4.1.0) lib/active_record/transactions.rb:326:in `with_transaction_returning_status'
activerecord (4.1.0) lib/active_record/persistence.rb:230:in `update'
app/controllers/posts_controller.rb:44:in `block in update'

I fixed it by refactoring the settings in the virtual_attributes initializer to using lazy attributes.