Rails 3 resource without prefix

I have a Mail resource in my application. The default paths for resources :postsgive URLs, for example /posts/:id. Is it possible to delete β€œmessages” from a route and have it instead /:id?

+3
source share
2 answers

You can use the :path'/ posts' bit to remove ...

resources :posts, :path => "/"

Just keep in mind that this may confuse other routes that are defined below in the routes file. For this reason, it is best to have this capture method.

+7
source

( routes.rb, )

match ':id' => 'posts#show'
+2

All Articles