diff --git a/CHANGELOG.md b/CHANGELOG.md index ed92ff3..bc99ff8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html ## Unreleased ### Compatible changes -- +- Fix error "undefined method `[]' for nil" due to missing code line in previous version ### Breaking changes - diff --git a/lib/rails_state_machine/model.rb b/lib/rails_state_machine/model.rb index a397f09..f64ae9e 100644 --- a/lib/rails_state_machine/model.rb +++ b/lib/rails_state_machine/model.rb @@ -36,6 +36,7 @@ def state_events(state_attribute = DEFAULT_STATE_ATTRIBUTE) private def state_machine_state_manager(state_attribute) + @state_machine_state_managers ||= {} @state_machine_state_managers[state_attribute] ||= StateManager.new(self, state_machine(state_attribute), state_attribute) end