Nested resources with nested controllers

Is there a way to create resources that work with nested controllers?
For example:

./script/generate scaffold_resource project name:string
mkdir app/views/layouts/project # so the command below doesn’t
complain
./script/generate scaffold_resource project::user name:string

routes.rb

map.resources :projects do |project|
project.resources :users
end

After creating a project and trying to list it’s users by using
/projects/1/users it will give the error:

Processing ApplicationController#index (for 127.0.0.1 at 2007-01-10
20:31:39) [GET]
Session ID: effe3a9a1b3131e75c4507fc92eb01d5
Parameters: {“project_id”=>“1”, “action”=>“index”,
“controller”=>“users”}

NameError (uninitialized constant UsersController):
//vendor/rails/activesupport/lib/active_support/dependencies.rb:267:in
‘load_missing_constant’

etc

Looking in rails/railties/lib/rails_generator/generators/compon
ents/scaffold_resource/scaffold_resource_generator.rb there seems to be
some logic for nesting controllers but I can’t figure out how it is
supposed to be used.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs