1

我正在学习 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

知道为什么用户没有被重定向到登录吗?现在,用户只是被显示在他只能看到是否经过身份验证的页面。

谢谢!

4

1 回答 1

1

改变这一行:

before_filter :authenticate_user!, :only => [:edit, :update, :destroy]

before_filter :authenticate_user!, :only => [:index, :edit, :update, :destroy]
于 2012-04-17T18:04:52.040 回答