我使用我的導軌3應用程序的設計。出於某種原因,使用「記住我」登錄不起作用。設計 - 記住我不工作? LocalHost問題?
這可能是由於在localhost:3000上測試?
在devise.rb,我有以下設置:
config.remember_for = 2.weeks
在日誌中,當我發佈一個登入我看到:
Started POST "https://stackoverflow.com/users/sign_in" for 127.0.0.1 at Thu May 12 20:53:04 -0700 2011
Processing by SessionsController#create as HTML
Parameters: {"signIn"=>"LOG IN", "authenticity_token"=>"GR09TIq4uSbu6UWxDRhpfQeLWp7qtJTxkCFksLmFzdE=", "utf8"=>"✓", "user"=>{"remember_me"=>"on", "password"=>"[FILTERED]", "email"=>"[email protected]"}}
這有什麼錯呢?
我也有我的sessions_controller.rb
class SessionsController < Devise::SessionsController
prepend_before_filter :require_no_authentication, :only => [ :new, :create ]
include Devise::Controllers::InternalHelpers
# GET /resource/sign_in
def new
clean_up_passwords(build_resource)
render_with_scope :new
end
# POST /resource/sign_in
def create
resource = warden.authenticate!(:scope => resource_name, :recall => "new")
#set_flash_message :notice, :signed_in
sign_in_and_redirect(resource_name, resource)
end
# GET /resource/sign_out
def destroy
#set_flash_message :notice, :signed_out if signed_in?(resource_name)
sign_out_and_redirect(resource_name)
end
protected
def after_sign_in_path_for(resource)
if resource.is_a?(User) && resource.banned?
sign_out resource
flash[:error] = "This account has been suspended."
root_path
else
super
end
end
end
任何想法,爲什麼登錄和記憶不工作下列?謝謝
當我關閉瀏覽器並返回到本地主機:3000網址我不得不重新登錄,我也看到該cookie沒有設定過期日期 – AnApprentice 2011-05-13 03:59:00