views:

24

answers:

1

I've decided to put a landing page on my website goldhat.org. I want users to be able to go directly to this page if they are logged in and be directed to a landing page if they aren't logged in. The landing page is currently sitting here. If one clicks on the "browse website" link at the top, it will go to what is currently the home page.

Basically I want the landing page and what is currently the home page to share the "www.goldhat.org" web address. I can see how this is easy enough to do with a logged in? conditional, but what about someone who isn't logged in and browses the site. I only really want the landing page to be displayed once.

Any ideas?

+2  A: 

Use a session variable to keep track of whether a visitor that is not logged in has viewed the landing page or not. Something along the lines of:

def index
  if !logged_in? && !session[:visited_welcome_page]
    redirect_to welcome_path
  else
    # Render the main view of goldhat.org
  end
end

def welcome
  session[:visited_welcome_page] = true
  # Render welcome view
end
Pär Wieslander
Sounds great! Will give it a go.
Kenji Crosland
Worked like a charm. Thanks!
Kenji Crosland
I suggest doing the logged_in? thing on your Application controller with a before_filter. Otherwise you will repeat yourself a lot.
egarcia