如何编写form_for而不:url用于多个对象编辑?

时间:2012-03-06 12:34:04

标签: ruby-on-rails forms multiple-records

我关注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

0 个答案:

没有答案