Joined July 2014
·

Errin Larsen

Developer
·
Hoover, Alabama
·
·
·

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 hope this helps somebody!

Achievements
1 Karma
0 Total ProTip Views
Interests & Skills