나는 news_ownload와 같은 몇 가지 모델을 has_many comments : as => : commentable로 보유하고 있습니다. 댓글 belongs_to : 댓글 가능 : 다형성 : 의견과 마찬가지로 구독도 있습니다. 따라서 내 경로는 다음과 같습니다.여러 모델에 대한 반복 경로 DRYing
resources :news do
resources :comments do
post :like, :on => :member
delete :like, :on => :member
end
resources :subscriptions
...
end
resources :downloads do
resources :comments do
post :like, :on => :member
delete :like, :on => :member
end
resources :subscriptions
...
end
...
건조가 가능한 방법이 있습니까? 나는 routes.rb의 다음 상단에
def comment_resources
resources :comments do
# ...
end
resources :subscriptions
end
을 정의하고 comment_resources를 호출 시도했지만이 제대로 클래스/네임 스페이스되지 않기 때문에 그것은 나에게 더러운 보인다. 당신은 뉴스 및 다운로드 모두 정확히 같은 내부 루트가있는 경우
아, 날짜에보고해야 ... – sandrew