简体   繁体   English

使用Devise,如何将根页面设置为如果用户注销则不重定向到“ sign_in”页面?

[英]Using Devise, how can I set the root page to not redirect to the “sign_in” page if the user is logged out?

I would like to populate the root page with certain items from my database and just have a link to sign in somewhere on the page. 我想用数据库中的某些项目填充根页面,并且只有链接可以登录页面上的某处。 Basically I don't want to make the content exclusive to those who are logged in. 基本上,我不想让登录用户独享该内容。

In your root controller, just add: 在您的根控制器中,只需添加:

skip_before_filter :authenticate_user!

Example: 例:

class RootController < ApplicationController
  skip_before_filter :authenticate_user!

  def index
    #some logic here
  end
end

You can also limit it to just the index action: 您还可以将其限制为仅索引操作:

skip_before_filter :authenticate_user!, only: [:index]

Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM