[英]Ruby on Rails / Devise: Determining in model if user is logged in
[英]Ruby on Rails - devise not making the user log in when the user is not logged in
我正在學習Ruby和Devise,由於某些原因,未登錄的用戶不會重定向到登錄狀態。
這是我的路線:
scope :module => :mobile, :as => :mobile do
constraints(:subdomain => /m/) do
devise_for :users, :path => "", :path_names => { :sign_in => "login", :sign_out => "logout", :sign_up => "signup" }, :controllers => {:sessions => "sidebar/sessions"}
resources :home
resources :disclosures # Will have new, get, look up a disclosure
devise_for :users, :path => "", :path_names =>
{ :sign_in => "login", :sign_out => "logout", :sign_up => "signup" }
end
end
這是我的控制器:
class Mobile::HomeController < ApplicationController
layout "mobile/application"
before_filter :authenticate_user!, :only => [:edit, :update, :destroy]
def index
respond_to do |format|
format.html
end
end
def create
end
end
知道為什么不將用戶重定向到登錄嗎? 現在,僅向用戶顯示該頁面,他只能在此頁面上查看是否經過身份驗證。
謝謝!
更改此行:
before_filter :authenticate_user!, :only => [:edit, :update, :destroy]
至
before_filter :authenticate_user!, :only => [:index, :edit, :update, :destroy]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.