我正在学习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
知道为什么没有重定向用户登录?现在,只是向用户显示他只能看到是否经过身份验证的页面。
谢谢!
答案 0 :(得分:1)
更改此行:
before_filter :authenticate_user!, :only => [:edit, :update, :destroy]
到
before_filter :authenticate_user!, :only => [:index, :edit, :update, :destroy]