Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue initial state doesn't work in active_record 4.2 #335

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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