2

情况是我想要一个表,其中每一行都是一个表来更新单个记录,而不是复杂的东西。这是代码:

%table.table.datatable
  %thead
    %tr
      %th Post ID
      %th Name
      %th Title
      %th
  %tbody
    -if @posts.present?
      - @posts.each do |post|
        %tr
          = simple_form_for post, url: admin_post_path(post), method: :put do |f|
            %td
              = post.id
            %td
              = post.author.name
            %td
              = f.input :title, label: false, input_html: {class: 'input-medium'}
            %td
              = f.submit 'Update', class: 'btn btn-success'

看起来很简单,但它不适用于错误:

Routing Error: No route matches [POST]

然而,这可以通过删除 jQuery 数据表来实现:

-#from %table.table.datatable    
%table.table 

这是我的 routes.rb 的一部分:

namespace :admin, :path => 'welab' do
  ...
  resources :posts
  ...
end

该解决方案可能是更新“标题”的解决方法。但是在这种情况下我不能有 jQuery 数据表吗?

4

0 回答 0