目前我的路线如下
namespace :books
resources :pages, only: [] do
post 'lesson'
end
end
路径:DB/DB_id/user/user_id/books/pages/page_id/lesson
如何更新支持以下路径的路线?
DB/DB_id/user/user_id/books
我没有传递任何book_id。只想列出所有书籍
答案 0 :(得分:0)
namespace :books
get "/", to: "books#index"
resources :pages, only: [] do
post 'lesson'
end
end
当然,如果你最终想要访问个人书籍,你会希望将书籍作为资源,以便以后轻松添加路线。
resources :books, only: [:index] do
resources :pages, only: [] do
post 'lesson'
end
end