:only option in route 2.2.2

Hi

I have my application rails version 2.2.2 And this thing

map.resources :users, :only => [:index] do |u|
u.resources :categories
end

when I tried this in 2.3.2 rails I get what I required Means it only
cretes user index and then all other routes for categories …But when I
tried it on 2.2.2 version it only created index for both user and
categories Could you please suggest how I can solve this?

Thanks in advance
Sijo

Hi
I think I could solve this by writing in 2.2.2 like this…Could I?

map.resources :users, :only => [:index] do |u|
u.resources :categories, except => []
end

And the routes generated in 2.2.2

                  users GET    /users 

{:controller=>“users”, :action=>“index”}
formatted_users GET /users.:format
{:controller=>“users”, :action=>“index”}
user_categories GET /users/:user_id/categories
{:controller=>“categories”, :action=>“index”}
formatted_user_categories GET /users/:user_id/categories.:format
{:controller=>“categories”, :action=>“index”}
POST /users/:user_id/categories
{:controller=>“categories”, :action=>“create”}
POST /users/:user_id/categories.:format
{:controller=>“categories”, :action=>“create”}
new_user_category GET /users/:user_id/categories/new
{:controller=>“categories”, :action=>“new”}
formatted_new_user_category GET
/users/:user_id/categories/new.:format {:controller=>“categories”,
:action=>“new”}
edit_user_category GET /users/:user_id/categories/:id/edit
{:controller=>“categories”, :action=>“edit”}
formatted_edit_user_category GET
/users/:user_id/categories/:id/edit.:format {:controller=>“categories”,
:action=>“edit”}
user_category GET /users/:user_id/categories/:id
{:controller=>“categories”, :action=>“show”}
formatted_user_category GET
/users/:user_id/categories/:id.:format {:controller=>“categories”,
:action=>“show”}
PUT /users/:user_id/categories/:id
{:controller=>“categories”, :action=>“update”}
PUT
/users/:user_id/categories/:id.:format {:controller=>“categories”,
:action=>“update”}
DELETE /users/:user_id/categories/:id
{:controller=>“categories”, :action=>“destroy”}
DELETE
/users/:user_id/categories/:id.:format {:controller=>“categories”,
:action=>“destroy”}

In 2.3.2

I wrote

map.resources :users, :only => [:index] do |u|
u.resources :categories
end

And routes are

      users GET    /users(.:format) 

{:action=>“index”, :controller=>“users”}
user_categories GET /users/:user_id/categories(.:format)
{:action=>“index”, :controller=>“categories”}
POST /users/:user_id/categories(.:format)
{:action=>“create”, :controller=>“categories”}
new_user_category GET /users/:user_id/categories/new(.:format)
{:action=>“new”, :controller=>“categories”}
edit_user_category GET /users/:user_id/categories/:id/edit(.:format)
{:action=>“edit”, :controller=>“categories”}
user_category GET /users/:user_id/categories/:id(.:format)
{:action=>“show”, :controller=>“categories”}
PUT /users/:user_id/categories/:id(.:format)
{:action=>“update”, :controller=>“categories”}
DELETE /users/:user_id/categories/:id(.:format)
{:action=>“destroy”, :controller=>“categories”}
/:controller/:action/:id
/:controller/:action/:id(.:format)

Sijo

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs