In my application I have 2 pages. 1 for signed out users who come on the site called welcome and another for signed in users called home:
Here are my routes:
namespace :user do
root :to => "home#index"
end
root :to => "pages#welcome"
match '/welcome', :to => 'pages#welcome'
match '/home', :to => 'home#index'
I use before_filter :authenticate_user! for my HomeController so they land on the welcome page if signed out.
How can I make so Signed in user cannot access the welcome page?
Answer
class PagesController < ApplicationController
def welcome
@title = "Welcome"
if signed_in?
redirect_to home_path
end
end
end
In the “welcome” action, just redirect them to the “home” action if they’re signed in. ie redirect both ways, depending on signed-in-edness 🙂