Skip to content

Instantly share code, notes, and snippets.

@osdezwart
Created July 3, 2010 21:02
Show Gist options
  • Save osdezwart/462837 to your computer and use it in GitHub Desktop.
Save osdezwart/462837 to your computer and use it in GitHub Desktop.
namespace :admin do
resources :users
resources :events
resources :routes
resources :comments, :member => {:reject => :get, :aprove => :get }
end
this doesn't work when I run rake routes I get
GET /admin/comments(.:format) {:action=>"index", :controller=>"admin/comments", :member=>{:reject=>:get, :aprove=>:get}}
admin_comments POST /admin/comments(.:format) {:action=>"create", :controller=>"admin/comments", :member=>{:reject=>:get, :aprove=>:get}}
new_admin_comment GET /admin/comments/new(.:format) {:action=>"new", :controller=>"admin/comments", :member=>{:reject=>:get, :aprove=>:get}}
GET /admin/comments/:id(.:format) {:action=>"show", :controller=>"admin/comments", :member=>{:reject=>:get, :aprove=>:get}}
PUT /admin/comments/:id(.:format) {:action=>"update", :controller=>"admin/comments", :member=>{:reject=>:get, :aprove=>:get}}
admin_comment DELETE /admin/comments/:id(.:format) {:action=>"destroy", :controller=>"admin/comments", :member=>{:reject=>:get, :aprove=>:get}}
edit_admin_comment GET /admin/comments/:id/edit(.:format) {:action=>"edit", :controller=>"admin/comments", :member=>{:reject=>:get, :aprove=>:get}}
root / {:controller=>"pages", :action=>"home"}
so the :member part is added as a paramter to the request instead of creating additional routes.
# This setup moves the comments route
namespace :admin do
resources :users
resources :events
resources :routes
map.resources :comments, :member => {:reject => :get, :aprove => :get }
end
this doesn't work either running rake routes I get
comments GET /comments(.:format) {:controller=>"comments", :action=>"index"}
POST /comments(.:format) {:controller=>"comments", :action=>"create"}
new_comment GET /comments/new(.:format) {:controller=>"comments", :action=>"new"}
edit_comment GET /comments/:id/edit(.:format) {:controller=>"comments", :action=>"edit"}
reject_comment GET /comments/:id/reject(.:format) {:controller=>"comments", :action=>"reject"}
aprove_comment GET /comments/:id/aprove(.:format) {:controller=>"comments", :action=>"aprove"}
comment GET /comments/:id(.:format) {:controller=>"comments", :action=>"show"}
PUT /comments/:id(.:format) {:controller=>"comments", :action=>"update"}
DELETE /comments/:id(.:format) {:controller=>"comments", :action=>"destroy"}
the comments are suddenly not in the admin namespace anymore.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment