Open fly1tkg opened 9 years ago
The initial state won't persist to the database.
Hello guys how do i apply this fix to the state-machine gem
Hey Destino92, if you you want to monkey patch it, you can create a file
config/initializers/state_machine.rb
with
# Hacks around https://github.com/pluginaweek/state_machine/issues/334
module StateMachine
module Integrations
module ActiveRecord
def define_state_initializer
define_helper :instance, <<-end_eval, __FILE__, __LINE__ + 1
def initialize(*)
super do |*args|
self.class.state_machines.initialize_states self
yield(*args) if block_given?
end
end
end_eval
end
end
end
end
This PR is for https://github.com/pluginaweek/state_machine/issues/334 .