KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm having a bit of a problem with route namespaces that I've not encountered before. This is actually a part of some gem development I'm doing - but i've reworked the problem to fit with a more generic rails situation. Basically, I have a namespaced route, but I want it to direct to a generic (top-level) controller. My controller is PublishController , which handles publishing of many different types of Models - which all conform to the same interface, but can be under different namespaces. My routes look like this: # config/routes.rb namespace :manage do resources :projects do get 'publish' => 'publish#create' get 'unpublish' => 'publish#destroy' end end The problem is that this creates the following routes: manage_project_publish GET /manage/projects/:project_id/publish(.:format) {:controller=>"manage/publish", :action=>"create"} manage_project_unpublish GET /manage/projects/:project_id/unpublish(.:format) {:controller=>"manage/publish", :action=>"destroy"} Which is the routes I want, just not mapping to the correct controller. I've tried everything I can think of try and allow for the controller not to carry the namespace, but I'm stumped. I know that I could do the following: get 'manage/features/:feature_id/publish' => "publish#create", :as => "manage_project_publish" which produces: manage_project_publish GET /manage/projects/:project_id/publish(.:format) {:controller=>"publish", :action=>"create"} but ideally, I'd prefer to use the nested declaration (for readability) - if it's even possible; which I'm starting to think it isn't.
Tags (comma-separated)
Save Edits
Cancel