我关注http://railscasts.com/episodes/52-update-through-checkboxes。表格可以这样写:<% form_tag update_multiple_products_path, :method => :put do %>
。这不会生成正确的操作(action =“/ products”),因此我必须手动设置操作URL。
在没有:url参数的情况下写一下form_for吗?
我的设置:
# index.html.erb
<%= form_for update_multiple_products_path, :url => {:action => 'update_multiple'}, :method => :put do %>
# routes.rb
resources :products do
collection do
put :update_multiple
end
end
# productscontroller
class ProductsController < ApplicationController
...
def update_multiple