我有以下routes.rb
resources :authors do
resources :books, only: [:create, :read] do
post "read"
end
end
我希望命名路由为read_authors_books
,但它生成为authors_books_read
,有没有办法更改命名路由?
我已尝试post "read" as: :read_authors_books
,但会将其生成为authors_books_read_authors_books
答案 0 :(得分:0)
将:read
设为member_route
resources :authors do
resources :books, only: [:create] do
post :read, on: :member
end
end
这将生成
read_author_book POST /authors/:author_id/books/:id/read(.:format) books#read
author_books POST /authors/:author_id/books(.:format) books#create