1

这是我的类别控制器代码

   class CategoriesController < ApplicationController

     before_filter :authenticate_user! ,:except => :index

     def index
       #some code
     end

     def show
       #some code
     end

   end  

很明显,您可以看到我的 categories#index 页面是公开可见的,其中列出了所有类别。当任何人在没有登录的情况下单击类别名称时,他/她将被重定向到“localhost:3000/users/sign_in”。

但我希望该用户在设计 before_filter 时被重定向到“www.facebook.com”之类的网址:authenticate_user!工作。

我怎么能做到这一点?

4

0 回答 0