简体   繁体   中英

Namespaced routes in rails 1

I'm working with some legacy code with the last version of rails 1. Upgrading to a later version of rails isn't possible and as such map.namespace is a private method in this version, otherwise I'd be using it.

I have several resources which I have nested into a submenu for simplicity. Their controllers are all within the folder of that submenu and all inherit that controller's namespace.

I'm having major issues with the sub elements. I have mapped the resources and applied a prefix to them in the form of

map.resources :subitem, :path_prefix => "/sub_menu"

but I'm having major issues with using RESTFul methods on these nested objects. The paths that I'm trying to use, say to delete an object simply do not work.

I'm refactoring this current code base so there's very little I can do, and there's very little I can find on rails 1 routes online. It's a bit of a finicky issue but maybe I've missed something simple about routes.

Do I simply need to manually write out every particular route I can use and then manually prefix it, or is there a simpler way?

My other routes work fine, I simply cannot use the

subitem_path(subitem) :method => :delete

function in my link to

So I figured out how to layout the routes appropriately so I could access the paths

Add to the above route the specified controller you're using and the routes will map accordingly

map.resources :subitem, :path_prefix => "/sub_menu, :controller => "submenu/subitem"

Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM