lib/devise/models/rememberable.rb in devise-2.0.6 vs lib/devise/models/rememberable.rb in devise-2.1.0.rc
- old
+ new
@@ -22,11 +22,11 @@
# the user. By default remember_for is 2.weeks.
#
# * +extend_remember_period+: if true, extends the user's remember period
# when remembered via cookie. False by default.
#
- # * +cookie_options+: configuration options passed to the created cookie.
+ # * +rememberable_options+: configuration options passed to the created cookie.
#
# == Examples
#
# User.find(1).remember_me! # regenerating the token
# User.find(1).forget_me! # clearing the token
@@ -39,10 +39,14 @@
module Rememberable
extend ActiveSupport::Concern
attr_accessor :remember_me, :extend_remember_period
+ def self.required_fields(klass)
+ [:remember_created_at, :remember_token]
+ end
+
# Generate a new remember token and save the record without validations
# unless remember_across_browsers is true and the user already has a valid token.
def remember_me!(extend_period=false)
self.remember_token = self.class.remember_token if generate_remember_token?
self.remember_created_at = Time.now.utc if generate_remember_timestamp?(extend_period)
@@ -69,10 +73,10 @@
end
def rememberable_value
if respond_to?(:remember_token)
remember_token
- elsif salt = authenticatable_salt
+ elsif respond_to?(:authenticatable_salt) && (salt = authenticatable_salt)
salt
else
raise "authenticable_salt returned nil for the #{self.class.name} model. " \
"In order to use rememberable, you must ensure a password is always set " \
"or have a remember_token column in your model or implement your own " \