The reason that no one has a “definitive” guide to routing syntax is that it is quite flexible, so you could probably write a few chapters on just one issue. However, I would recommend: http://guides.rubyonrails.org/routing.html
From your question, it looks like you are in the modelB
namespace under modelA
, but also want the id
for modelA
be inside the route itself.
So, if your ModelBController
looks something like this:
class ModelA::ModelBController < ApplicationController
then you can just do:
resources :modelA do resources :modelB, :module => :modelA end
However, are you sure you want to skip the controller namespace? If you just need nested resources, like the typical has_many
relation, you don’t need to place modelB
names under modelA
.
Instead, you will have:
/app /controllers /modelA
And your modelB
controller:
class ModelBController < ApplicationController
Then you could do
resources :modelA do resources :modelB end
iwasrobbed
source share