I realize this post is old, but I found my way here with a Google search, so I imagine others might, too, and in that case, I thought I should share a fix to the code listed here.
Following the example, I was receiving a "NoMethodError: undefined method state_machine for Acceptable" exception. I modified the code as follows to fix the issue:
module Acceptable
def self.included(base)
base.state_machine :initial => :new do
# ... code removed for brevity
end
end
end
I'm not sure if the original code worked when this was first posted, but StateMachine now defines the #state_machine method on Class, and so the listed Module (above; i.e. Acceptable) can't find it. However, you can call the #state_machine method on the base Class, which is passed as an argument to .included.
I realize this post is old, but I found my way here with a Google search, so I imagine others might, too, and in that case, I thought I should share a fix to the code listed here.
Following the example, I was receiving a "NoMethodError: undefined method
state_machine
for Acceptable" exception. I modified the code as follows to fix the issue:I'm not sure if the original code worked when this was first posted, but StateMachine now defines the
#state_machine
method on Class, and so the listed Module (above; i.e. Acceptable) can't find it. However, you can call the#state_machine
method on thebase
Class, which is passed as an argument to.included
.I hope this helps somebody!