Skip to content

Conversation

@fly1tkg
Copy link

@fly1tkg fly1tkg commented Dec 25, 2014

This PR is for #334 .

@seuros
Copy link

seuros commented Jan 16, 2015

The initial state won't persist to the database.

@destino92
Copy link

Hello guys how do i apply this fix to the state-machine gem

@shushugah
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants