简体   繁体   中英

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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