Created
May 28, 2015 06:15
-
-
Save mlarraz/86a0c1deabe8e5333b7a to your computer and use it in GitHub Desktop.
state_machines-activemodel not respecting aliases on initialize
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'state_machines-activemodel' | |
class Foo | |
include ActiveModel::Model | |
attr_accessor :status | |
alias_attribute :state, :status | |
state_machine initial: :new | |
end | |
a = Foo.new(state: :old) | |
puts a.state # :old | |
puts a.status # :old | |
a.status = :new | |
puts a.status # :new | |
puts a.state # :new | |
b = Foo.new(status: :old) | |
puts b.state # :new | |
puts b.status # :new | |
b.status = :old | |
puts b.status # :old | |
puts b.state # :old |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment