Search code examples
ruby-on-railsruby-on-rails-3ruby-on-rails-3.1routesnested-resources

resource available output parent resource rails 3.2


I have this in my routes.rb

resources :users, :path => "/", :only => [:show] do
  resources :collections, :controller => 'users/collections'
end

Why can I access to collections resources from:

http://localhost:3000/en/collections

if this resouce this inside users?

I want that collection resource only is enable inside:

http://localhost:3000/en/users/collections

This is my routes:

user_collections GET    (/:locale)/:user_id/collections(.:format)          users/collections#index
                         POST   (/:locale)/:user_id/collections(.:format)          users/collections#create
     new_user_collection GET    (/:locale)/:user_id/collections/new(.:format)      users/collections#new
    edit_user_collection GET    (/:locale)/:user_id/collections/:id/edit(.:format) users/collections#edit
         user_collection GET    (/:locale)/:user_id/collections/:id(.:format)      users/collections#show
                         PUT    (/:locale)/:user_id/collections/:id(.:format)      users/collections#update
                         DELETE (/:locale)/:user_id/collections/:id(.:format)      users/collections#destroy

How can I do it?

Thank you


Solution

  • Try this:

    resources :users, :only => [:show] do
      resources :collections, :controller => 'users/collections'
    end