Devise logged in root route rails 3

Oluf Nielsen picture Oluf Nielsen · Sep 24, 2010 · Viewed 13.4k times · Source

Heyya guys. So i thought about this coolio idea, if you are logged in then you get some sort of dashboard, else you get an information/login/sign up page.. So how do i do that..

I mostly wants to do this in Routes = not something like


def index
  if current_user.present?
    render :action => 'logged_in'
  else
    render :action => 'logged_out'
  end
end

thanks in advance!

/ Oluf Nielsen

Answer

Joe Lalgee picture Joe Lalgee · Dec 8, 2010

Think you may have been looking for this:

authenticated :user do
  root :to => "dashboard#show"
end

root :to => "devise/sessions#new"

Note: it's authenticate*d*