Skip to content

Instantly share code, notes, and snippets.

@mlarraz
Created May 28, 2015 06:15
Show Gist options
  • Save mlarraz/86a0c1deabe8e5333b7a to your computer and use it in GitHub Desktop.
Save mlarraz/86a0c1deabe8e5333b7a to your computer and use it in GitHub Desktop.
state_machines-activemodel not respecting aliases on initialize
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