I have a Rails engine, MyEngine , which does not have an isolated namespace. I am trying to use polymorphic helpers to create resource references, according to docs .
Engine Route:
# config/routes.rb ... namespace :admin do resources :my_resource end ...
Example output for rake app:routes (remember, this is the engine):
admin_my_resources GET /admin/my_resources(.:format) my_engine/admin/my_resources#index POST /admin/my_resources(.:format) my_engine/admin/my_resources#create new_admin_my_resource GET /admin/my_resources/new(.:format) my_engine/admin/my_resources#new edit_admin_my_resource GET /admin/my_resources/:id/edit(.:format) my_engine/admin/my_resources#edit admin_my_resource PUT /admin/my_resources/:id(.:format) my_engine/admin/my_resources#update DELETE /admin/my_resources/:id(.:format) my_engine/admin/my_resources
If my_resource is an instance of the my_resource model with id 12345 , I would expect:
polymorphic_url([my_engine, :admin, my_resource])
for rendering:
/my_engine/admin/my_resource/12345
but I was wrong. Instead, I get an exception:
undefined method `admin_my_engine_my_resource_path'...
So polymorphic_url trying to use admin_my_engine_my_resource_path where it really should use something more like my_engine.admin_my_resource_path(my_resource)
Rails seems to add :admin wrong way ... or am I doing it wrong?
source share