Devise: Sign Up Page as Welcome/Landing Page then to User Profile

后端 未结 5 718
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-01 08:57

Using devise, how do i make my Sign Up as my landing/welcome page and then after sign up they go inside the site to the Profile/signed in area?

I am trying to figure out

5条回答
  •  死守一世寂寞
    2021-02-01 09:32

    I find it easiest to root to the desired authenticated landing page and just use a before_filter to force the user to sign in/sign up first via a before_filter.

    In this case, let's say your "signed in area" is a controller/action called profile/index.

    In your routes.rb, set the root to profile/index.

    root :to => 'profile#index'
    

    Then in your profile_controller, set the following before_filter.

    before_filter :authenticate_user!
    

    This will automatically push a logged in user (or one that logged in earlier and set a Remember Me cookie) straight to the profile page. Any unauthenticated users will automatically end up on Sign In. You'll want a link (or separate tab) on that page to Sign Up as well.

提交回复
热议问题