views:

1136

answers:

2
map.resources :users
map.namespace :formulator do |formulator|
    formulator.resources :submissions
end

I want to have submissions be a nested resource of users, but I'm not sure how to since it's namespaced.

+1  A: 

Have you tried anything like:

 map.resources :users
 map.namespace :formulator do |formulator|
   formulator.resources :submissions
   map.resources :users, :has_many => :submissions
 end

or this

 map.resources :users
 map.namespace :formulator do |formulator|
   formulator.resources :submissions
 end
 map.resources :users, :has_many => :submissions

If not, try running rake routes afterwards to see what it routes are generated.

vrish88
Which one worked for you?
vrish88
+1  A: 

You should be able to do this:

map.resources :users, :has_many => :submissions

Which will give you routes like this:

               users GET    /users(.:format)                               {:action=>"index", :controller=>"users"}
                     POST   /users(.:format)                               {:action=>"create", :controller=>"users"}
            new_user GET    /users/new(.:format)                           {:action=>"new", :controller=>"users"}
           edit_user GET    /users/:id/edit(.:format)                      {:action=>"edit", :controller=>"users"}
                user GET    /users/:id(.:format)                           {:action=>"show", :controller=>"users"}
                     PUT    /users/:id(.:format)                           {:action=>"update", :controller=>"users"}
                     DELETE /users/:id(.:format)                           {:action=>"destroy", :controller=>"users"}
    user_submissions GET    /users/:user_id/submissions(.:format)          {:action=>"index", :controller=>"submissions"}
                     POST   /users/:user_id/submissions(.:format)          {:action=>"create", :controller=>"submissions"}
 new_user_submission GET    /users/:user_id/submissions/new(.:format)      {:action=>"new", :controller=>"submissions"}
edit_user_submission GET    /users/:user_id/submissions/:id/edit(.:format) {:action=>"edit", :controller=>"submissions"}
     user_submission GET    /users/:user_id/submissions/:id(.:format)      {:action=>"show", :controller=>"submissions"}
                     PUT    /users/:user_id/submissions/:id(.:format)      {:action=>"update", :controller=>"submissions"}
                     DELETE /users/:user_id/submissions/:id(.:format)      {:action=>"destroy", :controller=>"submissions"}
Mr. Matt