view:
<%= button_to t('home.add_to_cart'), line_items_path(product)%>
这样点击按钮的时候直接 http://localhost:3000/line_items.4 把 product 的 id 变成了 format.
求原因! PS:
Prefix Verb URI Pattern Controller#Action
line_items GET /line_items(.:format) line_items#index
POST /line_items(.:format) line_items#create
new_line_item GET /line_items/new(.:format) line_items#new
edit_line_item GET /line_items/:id/edit(.:format) line_items#edit
line_item GET /line_items/:id(.:format) line_items#show
Log:
params {\"authenticity_token\"=>\"6q3Btd5+k83cNUOjW75NRLQFa5daONl/gb14xpMB5Fs=\", \"action\"=>\"create\", \"controller\"=>\"line_items\", \"format\"=>\"4\"}"
Completed 406 Not Acceptable in 69ms
ActionController::UnknownFormat (ActionController::UnknownFormat):
app/controllers/line_items_controller.rb:9:in `create'