polymorphic 중첩 리소스를 사용할 때 inherited_resources 문제가 발생합니다. 부모 중 하나가 네임 스페이스 컨트롤러입니다. 내가 /admin/projects/1/comments
에 액세스 할 때inherited_resources 'namespaced 컨트롤러가있는 polymorphic belongs_to를 사용할 수 없습니다.
# 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
, 나는이 오류를 얻을 : 여기에 추상적 인 예입니다 내가 Admin::CommentsController
같은 컨트롤러를 정의하면 이제
ActionController::RoutingError at /admin/projects/1/comments
uninitialized constant Admin::CommentsController
을, 나는 controllers/admin
에서 파일을 이동해야합니다 그러면 URL에 오류가 발생합니다. /tasks/1/comments
해결 방법이 있습니까?
감사합니다. 예, 이것은 하나의 해결책 이었지만,'inherited_resources'의 기본 목적 인'CommentsController'를 DRY 할 수 있는지 알아 내려고했습니다. 그렇지 않다면 나는 우려를 써서 두 주석 컨트롤러에 모두 포함시켜야 할 것이다. –