lib/devise/models/authenticatable.rb in devise-2.2.0 vs lib/devise/models/authenticatable.rb in devise-2.2.1

- old
+ new

@@ -166,10 +166,19 @@ def strip_whitespace self.class.strip_whitespace_keys.each { |k| apply_to_attribute_or_variable(k, :strip!) } end def apply_to_attribute_or_variable(attr, method) - (self[attr] || send(attr)).try(method) + if self[attr] + self[attr].try(method) + + # Use respond_to? here to avoid a regression where globally + # configured strip_whitespace_keys or case_insensitive_keys were + # attempting to strip! or downcase! when a model didn't have the + # globally configured key. + elsif respond_to?(attr) + send(attr).try(method) + end end module ClassMethods Devise::Models.config(self, :authentication_keys, :request_keys, :strip_whitespace_keys, :case_insensitive_keys, :http_authenticatable, :params_authenticatable, :skip_session_storage)