diff --git a/lib/devise/rails/warden_compat.rb b/lib/devise/rails/warden_compat.rb index 237be849..d1861b3d 100644 --- a/lib/devise/rails/warden_compat.rb +++ b/lib/devise/rails/warden_compat.rb @@ -21,17 +21,23 @@ class Warden::SessionSerializer end def deserialize(keys) - klass, *args = keys + klass_name, *args = keys begin - ActiveSupport::Inflector.constantize(klass).serialize_from_session(*args) + klass = ActiveSupport::Inflector.constantize(klass_name) + if klass.respond_to? :serialize_from_session + klass.serialize_from_session(*args) + else + Rails.logger.warn "[Devise] Stored serialized class #{klass_name} seems not to be Devise enabled anymore. Did you do that on purpose?" + nil + end rescue NameError => e if e.message =~ /uninitialized constant/ - Rails.logger.debug "[Devise] Trying to deserialize invalid class #{klass}" + Rails.logger.debug "[Devise] Trying to deserialize invalid class #{klass_name}" nil else raise end end end -end \ No newline at end of file +end