# Act\_as\_state\_machine (or aasm) to manage integer state?

**URL:** <https://www.ruby-forum.com/t/act-as-state-machine-or-aasm-to-manage-integer-state/168068>\
**Category:** Rails\
**Created:** [May 15, 2009, 1:06pm UTC](https://www.ruby-forum.com/t/act-as-state-machine-or-aasm-to-manage-integer-state/168068 "2009-05-15T13:06:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![triplem](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b19c9b/32.png) [@triplem](https://www.ruby-forum.com/u/triplem)\
**Post date:** [May 15, 2009, 1:06pm UTC](https://www.ruby-forum.com/t/act-as-state-machine-or-aasm-to-manage-integer-state/168068/1 "2009-05-15T13:06:34Z")

</div>

I have already done my model and i have managed state with an external  
table where with paperclip i appended an icon for every state.

But now i have some trouble with aasm, it seems it can’t use integer  
value as state, does anyone have had some similar case?

aasm\_column :state\_id  
aasm\_initial\_state :“1” #To print

aasm\_state :“1” #To print  
aasm\_state :“2” #Waiting  
aasm\_state :“3” #Selected

i’ve also tried to use something like this but naturally when i attempt  
to use transaction to change state i get an error

aasm\_column :state\_id  
aasm\_initial\_state :“1” #To print

aasm\_state :“1” #To print  
aasm\_state :“2” #Waiting  
aasm\_state :“3” #Selected

when i attempt to use transaction to change state i get this error:  
You have a nil object when you didn’t expect it!  
The error occurred while evaluating nil.name

D:/Marco/Progetti/Ruby/Rails232/Sviluppo/eMissive/vendor/plugins/rubyist-aasm-baceb4b53e296cd45ac3acbd5df291e14b2993aa/lib/state.rb:14:in  
`==' D:/Marco/Progetti/Ruby/Rails232/Sviluppo/eMissive/vendor/plugins/rubyist-aasm-baceb4b53e296cd45ac3acbd5df291e14b2993aa/lib/aasm.rb:123:in`aasm\_state\_object\_for\_state’  
C:/ruby/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.3.1/lib/ruby-debug/command.rb:119:in  
`find' D:/Marco/Progetti/Ruby/Rails232/Sviluppo/eMissive/vendor/plugins/rubyist-aasm-baceb4b53e296cd45ac3acbd5df291e14b2993aa/lib/aasm.rb:123:in`each’  
D:/Marco/Progetti/Ruby/Rails232/Sviluppo/eMissive/vendor/plugins/rubyist-aasm-baceb4b53e296cd45ac3acbd5df291e14b2993aa/lib/aasm.rb:123:in  
`find' D:/Marco/Progetti/Ruby/Rails232/Sviluppo/eMissive/vendor/plugins/rubyist-aasm-baceb4b53e296cd45ac3acbd5df291e14b2993aa/lib/aasm.rb:123:in`aasm\_state\_object\_for\_state’  
D:/Marco/Progetti/Ruby/Rails232/Sviluppo/eMissive/vendor/plugins/rubyist-aasm-baceb4b53e296cd45ac3acbd5df291e14b2993aa/lib/aasm.rb:129:in  
`aasm_fire_event' D:/Marco/Progetti/Ruby/Rails232/Sviluppo/eMissive/vendor/plugins/rubyist-aasm-baceb4b53e296cd45ac3acbd5df291e14b2993aa/lib/aasm.rb:62:in`review!’  
D:/Marco/Progetti/Ruby/Rails232/Sviluppo/eMissive/app/controllers/admin/letters\_controller.rb:195:in  
`print' D:/Marco/Progetti/Ruby/Rails232/Sviluppo/eMissive/app/controllers/admin/letters_controller.rb:176:in`print’

---

<div class="post-metadata">

**Author:** ![triplem](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b19c9b/32.png) [@triplem](https://www.ruby-forum.com/u/triplem)\
**Post date:** [May 19, 2009, 9:21am UTC](https://www.ruby-forum.com/t/act-as-state-machine-or-aasm-to-manage-integer-state/168068/2 "2009-05-19T09:21:05Z")

</div>

Doesn’t anyone know how to do or if exist a fork which is able to do  
this? It’s a pity to don’t use this helpful plugin and was perfect for  
my purpose
