Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to map root to a resource in rails?

I got a resource called posts, now i want to map root to posts as a resource. so as the result:

'/posts' => nothing

'/posts/1' => nothing

but

'/' => posts#index

'/1' => posts#show

like image 403
Andy Avatar asked Apr 03 '12 11:04

Andy


Video Answer


1 Answers

In config/routes.rb change

resources :posts

to:

resources :posts, :path => '/'
like image 96
davidb Avatar answered Oct 12 '22 03:10

davidb