[Ruby] acts_as_state_machine question

Frederick Alger fred at fredalger.net
Wed Nov 8 21:04:05 PST 2006


> My solution?
>
> class Order
> # ...
>    def after_initialize
>      set_initial_state
>    end
> # ...
> end

Yes, well that doesn't work either.  after_initialize is called after  
after_find, so all Order objects end up in state 'new'...  My new  
solution:

class Order
# ...
    def after_initialize
      set_initial_state if self.new_record?
    end
end


OK, enough about this already.
- Fred out.


More information about the Ruby mailing list