I have generated a resource named “fax” in the users_manager engine:
apple@apple1:~/jiuhe/users_manager$ rails g resource users_manager/fax
invoke active_record
create db/migrate/20111129123558_create_users_manager_faxes.rb
create app/models/users_manager/fax.rb
identical app/models/users_manager.rb
invoke test_unit
create test/unit/users_manager/fax_test.rb
create test/fixtures/users_manager/faxes.yml
invoke controller
create app/controllers/users_manager/faxes_controller.rb
invoke erb
create app/views/users_manager/faxes
invoke test_unit
create test/functional/users_manager/faxes_controller_test.rb
invoke helper
create app/helpers/users_manager/faxes_helper.rb
invoke test_unit
create test/unit/helpers/users_manager/faxes_helper_test.rb
invoke assets
invoke js
create app/assets/javascripts/users_manager/faxes.js
invoke css
create app/assets/stylesheets/users_manager/faxes.css
route namespace :users_manager do resources :faxes end
And I wrote the configure/routes.rb
UsersManager::Engine.routes.draw do
namespace :users_manager do
resources :users do
resources :faxes
resources :emails
resources :qqs
resources :addresses
resources :telephones
end
end
match "/:action"=>"users_manager/account"
end
But the route helper users_manager_engine.users_manager_user_fax_path can’t work.
Rails give me a message:
undefined method `users_manager_user_fax_path' for
#<ActionDispatch::Routing::RoutesProxy:0x7f0ca0ab3520>
However the route helper users_manager_engine.users_manager_user_faxes_path exists.
Check “rake routes” in the console, you’ll discover that the singular of “faxes” in your routes is not “fax” but “faxis”.
So the correct route would be users_manager_user_faxis_path
If you’re not happy with that, you can edit or create a config/initializers/inflections.rb with