Closed Gurpartap closed 11 years ago
As I read from StateMachine::MacroMethods
documentation:
Because of the way the inclusion of modules works in Ruby, calling super() will not only call the superclass's initialize, but also initialize on all included modules. This allows the original state machine hook to get called properly.
Using initialize_state_machines
instead of super
in my model's initialize method solved the problem (since my model also had included modules).
:smile:
Things worked fine until I revisited my code a couple of months later using ruby-1.9.3 instead of the previous ruby-1.9.2. The class using state_machine can now not be initialized. This is the error I'm trying to troubleshoot.
I have tried understanding the code attributed in backtrace. If
super
is omitted from machine.rb:1965's block, things seem to work (would probably break something elsewhere). So I'm looking for an informed opinion on whether this is a bug with state_machine, or if I am implementing something incorrectly (remember, it works fine on 1.9.2).I'm using ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]. As tested, there was no such error with ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.2.0].
The project where state_machine is implemented, and the problem can be reproduced is here: https://github.com/Gurpartap/cognizant. Install the gem and run
sudo cognizantd --trace /path/to/gems/cognizant/examples/cognizantd.yml
to reproduce the error.Thank you.