使用 rails 简单形式一次更新多条记录

Using rails simple form to update multiple records at once

我正在尝试创建一个简单的表单,它有 2 个字段。但我想一次为多个活动记录设置这 2 个字段。我创建了一个名为 update multiple 的新控制器操作,但不知何故我的表单没有显示。我不确定如何使用活动记录执行此操作。这是我的代码:

<% simple_form_for @fulfillments,
 :url => admin_fulfillments_update_multiple_path,
 :method => :put,
 remote: true do |f| %>
  <%= f.hidden_field :ids, value: @fulfillments %>
  <%= f.input :shopper_id, id: 'fulfillment_shopper_id', collection: @shoppers, label_method: :name, value_method: :id, label: 'Shopper', include_blank: true%>
  <%= f.button :submit, :class => 'btn btn-success btn-sm submit-shopper-form' %>
<% end %>

@fulfillments 已经填充到控制器的不同操作中,现在我将它作为隐藏字段通过表单传递到另一个控制器操作。但不知何故

我不确定为什么我的表格没有显示。

您忘记了简单形式的 =: 你的:

<% simple_form_for @fulfillments,

正确:

<%= simple_form_for @fulfillments,

注意 <%=。在开头。