martinciu/state_machine-mongoid

Unable to run state_machine

Closed this issue · 2 comments

Hello i am having issues with your plugin. I have installed both state_machine and state_machine-mongoid gems. Both show up in the gem -list. I added them to my GemFile
and added the required in my config/application.rb.

when i do a rake routes i receive this error

rake aborted!
undefined method `state_machine' for main:Object

Here is a snipped of my code



  state_machine :initial => :pending
  state :pending
  state :converting
  state :converted, :enter => :set_new_filename
  state :error

  event :convert do
    transitions :from => :pending, :to => :converting
  end

  event :converted do
    transitions :from => :converting, :to => :converted
  end

  event :failed do
    transitions :from => :converting, :to => :error
  end

Any ideas on what may be the issue? I am running Rails 3.0.3

opsb commented

gem 'state_machine-mongoid', :require => 'state_machine' in my Gemfile does it for me

Thank opsb I found out it was the placement of the state flow instructions they need to be under the includes before everything else.