Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails routes root with nested resource

I have a nested resource in my routes.rb like this:

map.resources :users, :only => [:index] do |user|
  user.resources :projects
end

which gives me URLs like /users/2/projects, which will show all projects owned by user 2. After a user is signed in, I'd like this to be the root page, using map.root. How would I set map.root to enable this? I'm using devise, so I can get the current user with current_user, but I'm not sure this is available in routes.rb.

like image 541
Skilldrick Avatar asked Sep 26 '10 19:09

Skilldrick


1 Answers

We're solving this with a HomepageController that renders two different templates based on if current_user.

like image 174
Reactormonk Avatar answered Oct 23 '22 23:10

Reactormonk