I am facing an issue with inherited_resources when using a polymorphic nested resource, one of whose parents is a namespaced controller. Here is an abstract example:
# routes.rb
resources :tasks do
resources :comments
end
namespace :admin do
resources :projects do
resources :comments
end
end
# comments_controller.rb
class CommentsController < InheritedResources::Base
belongs_to :projects, :tasks, :polymorphic => true
end
When I access /admin/projects/1/comments
, I get this error:
ActionController::RoutingError at /admin/projects/1/comments
uninitialized constant Admin::CommentsController
Now if I define the controller as Admin::CommentsController
, I would need to move the file under controllers/admin
which will in turn throw up an error for the url /tasks/1/comments
Is there a way I can fix this?
Why not keep
CommentsController
where it is and make a separate controller for admin inadmin/comments_controller.rb?
that inherits from it?