在我的應用我有一個用戶模式,辦學模式,課程模式和課程模式。用戶或學校可以創建我已經通過多態關聯(當然belongs_to的:主存,和學校/用戶的has_many:課程,如:主存)設置課程和課程教學大綱HAS_ONE。我的問題是如何配置嵌套課程模型的路線,嵌套課程模型也有嵌套在其中的教學大綱模型。嵌套模型路線on Rails應用程序
resources :users do
resources :courses do
resources :syllabus
end
member do
put :enroll
end
end
resources :schools do
resources :courses do
resources :syllabuses
end
member do
put :apply, :enroll
end
end
,使用戶可以通過點擊課程頁面上的按鈕在課程註冊,在我的課程控制器我有:
def enroll
@course = Course.find(params[:id])
current_user.coursegroups.create(host_course_id: @course.id, role: 'applicant')
respond_with @course
end
所以,這是我的配置路線的正確方法?
有一個在[文檔]報價(http://guides.rubyonrails.org/routing.html#limits-to-nesting),說:_「資源不應該被嵌套超過10級深。」 _ – Stefan