【发布时间】:2020-05-28 05:24:52
【问题描述】:
我正在使用rails sortable gem 创建一个通过拖放对goodies 进行排序的表。
我遵循了文档并在我看来得到了这个:
<main class="container-fluid px-5">
<header class="text-center">
<h1 class="thin uppercase">Store Manager</h1>
</header>
<section>
<h2 class="color-spouse font-weight-bold">Product Categories (Goodies)</h2>
<table id="selectedColumn" class="table table-striped table-bordered table-sm" cellspacing="0" width="100%">
<thead>
<tr>
<th></th>
<th>Order</th>
<th>Category</th>
<th># Free</th>
<th># Paid</th>
<th>Actions</th>
</tr>
</thead>
<tbody class="sortable">
<% @goodies.each do |g, sortable_id| %>
<tr id="<%= sortable_id %>">
<td class="min"><i class="fas fa-grip-lines"></i></td>
<td class="min"><%= g.sort %></td>
<td><%= g.name %></td>
<% free = Variation.where(goody_id: g.id).where(price: 0).count %>
<td><%= free %></td>
<% paid = Variation.where(goody_id: g.id).where.not(price: 0).count %>
<td><%= paid %></td>
<td class="min">
<%= link_to '<i class="fas fa-pencil-alt"></i>'.html_safe, edit_goody_path(g), class: "grey-text" %>
<%= link_to '<i class="fas fa-trash"></i>'.html_safe, g, method: :delete, data: { confirm: 'Are you sure?' }, class: "grey-text" %>
</td>
</tr>
<% end %>
</tbody>
</table>
</section>
</main>
<%= content_for :additional_js do %>
<script>
$(document).ready(function() {
$(function() {
$('.sortable').railsSortable();
});
})
</script>
<% end %>
我的控制器中有这个:
def store_manager
@goodies = Goody.order(:sort).all
@variations = Variation.order(:sort).all
end
它确实可以按预期拖放。但是,当我这样做时,会出现此服务器错误:
Started POST "/sortable/reorder" for ::1 at 2020-05-18 21:13:47 -0700
Processing by SortableController#reorder as JSON
Parameters: {"rails_sortable"=>["", "", ""], "sortable"=>{"rails_sortable"=>["", "", ""]}}
(0.2ms) BEGIN
↳ /Users/lizbayardelle/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.4.2/lib/active_record/log_subscriber.rb:98
(0.2ms) ROLLBACK
↳ /Users/lizbayardelle/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.4.2/lib/active_record/log_subscriber.rb:98
Completed 500 Internal Server Error in 3ms (ActiveRecord: 0.4ms)
ActiveSupport::MessageVerifier::InvalidSignature - ActiveSupport::MessageVerifier::InvalidSignature:
然后当我刷新页面时,新订单没有保存。
我看不出这与 activerecord 有什么关系,因为其中大部分是用于 blob 和文件存储。谁能看到为什么会触发此错误?
【问题讨论】:
标签: ruby-on-rails