Forum: Ruby on Rails act_as_state_machine (or aasm) to manage integer state?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Marco M. (Guest)
on 2009-05-15 15:06
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'
Marco M. (Guest)
on 2009-05-19 11:21
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
This topic is locked and can not be replied to.