- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0 (0)
- 3.0.9 (38)
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (0)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (0)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1
- 6.1.7.7
- 7.0.0
- 7.1.3.2
- 7.1.3.4
- What's this?
You may wish to organize groups of controllers under a namespace. Most commonly, you might group a number of administrative controllers under an admin namespace. You would place these controllers under the app/controllers/admin directory, and you can group them together in your router:
namespace "admin" do resources :posts, :comments end
This will create a number of routes for each of the posts and comments controller. For Admin::PostsController, Rails will create:
GET /admin/photos GET /admin/photos/new POST /admin/photos GET /admin/photos/1 GET /admin/photos/1/edit PUT /admin/photos/1 DELETE /admin/photos/1
If you want to route /photos (without the prefix /admin) to Admin::PostsController, you could use
scope :module => "admin" do resources :posts, :comments end
or, for a single case
resources :posts, :module => "admin"
If you want to route /admin/photos to PostsController
(without the Admin |
module prefix), you could use |
scope "/admin" do resources :posts, :comments end
or, for a single case
resources :posts, :path => "/admin"
In each of these cases, the named routes remain the same as if you did not use scope. In the last case, the following paths map to PostsController:
GET /admin/photos GET /admin/photos/new POST /admin/photos GET /admin/photos/1 GET /admin/photos/1/edit PUT /admin/photos/1 DELETE /admin/photos/1