簡體   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?

我想用數據庫中的某些項目填充根頁面,並且只有鏈接可以登錄頁面上的某處。 基本上,我不想讓登錄用戶獨享該內容。

在您的根控制器中,只需添加:

skip_before_filter :authenticate_user!

例:

class RootController < ApplicationController
  skip_before_filter :authenticate_user!

  def index
    #some logic here
  end
end

您還可以將其限制為僅索引操作:

skip_before_filter :authenticate_user!, only: [:index]

祝好運!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM