Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

writing nested namespace routes on rail3

i use

rails g scaffold_controller admin/sub/Product name:string

to generate crud page,

now i need write route.rb file to map the admin_sub_product_controller,how to write this route file on rails3?

it's hard for me to write 2 level namespace mapping route

namespace admin do
    resource :products
end

this only wokrs for /admin/products,but for mapping admin/sub/proudcts how to write?

like image 543
mlzboy Avatar asked Jan 21 '23 04:01

mlzboy


1 Answers

namespace :admin do
  namespace :sub do
    resources :products
  end
end

rake routes

    admin_sub_products      GET    /admin/sub/products(.:format)          {:action=>"index", :controller=>"admin/sub/products"}
                            POST   /admin/sub/products(.:format)          {:action=>"create", :controller=>"admin/sub/products"}
    new_admin_sub_product   GET    /admin/sub/products/new(.:format)      {:action=>"new", :controller=>"admin/sub/products"}
    edit_admin_sub_product  GET    /admin/sub/products/:id/edit(.:format) {:action=>"edit", :controller=>"admin/sub/products"}
    admin_sub_product       GET    /admin/sub/products/:id(.:format)      {:action=>"show", :controller=>"admin/sub/products"}
                            PUT    /admin/sub/products/:id(.:format)      {:action=>"update", :controller=>"admin/sub/products"}
                            DELETE /admin/sub/products/:id(.:format)      {:action=>"destroy", :controller=>"admin/sub/products"}
like image 186
yspro Avatar answered Jan 29 '23 07:01

yspro