From 6a990c3e050b9e69072534c5e4ea4631d4b23216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20B=C3=B6ttger?= Date: Sat, 6 Dec 2014 11:31:20 +0100 Subject: [PATCH] circumventing a bug in Rails 3 #193 --- lib/aasm/persistence/active_record_persistence.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/aasm/persistence/active_record_persistence.rb b/lib/aasm/persistence/active_record_persistence.rb index 7e3abed..7af4815 100644 --- a/lib/aasm/persistence/active_record_persistence.rb +++ b/lib/aasm/persistence/active_record_persistence.rb @@ -164,7 +164,9 @@ module AASM # foo.aasm_state # => nil # def aasm_ensure_initial_state - if respond_to?(self.class.aasm.attribute_name) && send(self.class.aasm.attribute_name).blank? + # checking via respond_to? does not work in Rails <= 3 + # if respond_to?(self.class.aasm.attribute_name) && send(self.class.aasm.attribute_name).blank? # Rails 4 + if attributes.key?(self.class.aasm.attribute_name.to_s) && send(self.class.aasm.attribute_name).blank? aasm.enter_initial_state end end