I think you have two options.
Option 1
Either you should drop the :require => 'state_machine/core'
part. So the new line would look just like this:
gem 'state_machine'
Option 2
Or add this line to your class:
extend StateMachine::MacroMethods
For example:
require 'state_machine/core'
class Vehicle
extend StateMachine::MacroMethods
state_machine do
# ...
end
end
Explanation
Loading of the file 'state_machine/core'
disables extension of Class
. That means that method state_machine
will not be available in any class unless you call extend StateMachine::MacroMethods
.
Details here: https://github.com/pluginaweek/state_machine#core-extensions
Bonus hint
Consider using state_machines
gem (ending with "s") instead of original state_machine
gem.
gem 'state_machines'
gem 'state_machines-activerecord'
The original is not maintained anymore (I am not sure why) but the new one is updated from time to time and it might prevent some errors.