Created
December 25, 2014 20:05
-
-
Save bouchard/3df277e61284c2a2487d to your computer and use it in GitHub Desktop.
Hack to Get Rails 4.1.0.rc1 through 4.2.0 to work with state_machine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rails 4.1.0.rc1 through 4.2.0 and StateMachine don't play nice | |
# https://github.com/pluginaweek/state_machine/issues/295 | |
# https://github.com/pluginaweek/state_machine/issues/314 | |
require 'state_machine/version' | |
unless StateMachine::VERSION == '1.2.0' | |
# If you see this message, please test removing this file | |
# If it's still required, please bump up the version above | |
Rails.logger.warn "Please remove me, StateMachine version has changed." | |
end | |
module StateMachine::Integrations | |
module ActiveModel | |
public :around_validation | |
end | |
module ActiveRecord | |
public :around_save | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment