1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00

circumventing a bug in Rails 3 #193

This commit is contained in:
Thorsten Böttger 2014-12-06 11:31:20 +01:00
parent e48fcc1161
commit 6a990c3e05

View file

@ -164,7 +164,9 @@ module AASM
# foo.aasm_state # => nil # foo.aasm_state # => nil
# #
def aasm_ensure_initial_state 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 aasm.enter_initial_state
end end
end end