1

我有一个看起来像这样的结构:

修改

  • _形式
  • _miniform
  • 指数

我的索引显示如下:

  %span.right
    = render "modifications/form", modification: modification

Form 和 Miniform 几乎相同:

.modification-forms
  - if can? :reject, modification.model
    = form_tag modification_rejections_url, class: "inline", remote: true do |f|
      = hidden_field_tag :id, modification.model.id
      = submit_button "Reject", class: 'btn btn-danger'

  - if can? :approve, modification.model
    = form_tag modification_approvals_url, class: "inline", remote: true do |f|
      = hidden_field_tag :id, modification.model.id
      = submit_button "Approve" , class: 'btn btn-success'

与迷你格式

.modification-device-forms
  - if can? :reject, modification.model
    = form_tag modification_rejections_url, class: "inline", remote: true do |f|
      = hidden_field_tag :id, modification.model.id
      = submit_button "<i class='icon-remove'> </i>".html_safe

  - if can? :approve, modification.model
    = form_tag modification_approvals_url, class: "inline", remote: true do |f|
      = hidden_field_tag :id, modification.model.id
      = submit_button "<i class='icon-ok'> </i>".html_safe

当我渲染 _form 部分时,ajax 会按照您的预期执行。单击按钮后,该行消失。

但是,当我换成 miniform 时,它不再起作用。ajax 运行,但它不会删除该行。

我认为这是 Rails 约定混淆了,但我对 Rails 魔法不太擅长,并且不知道从哪里开始破译这个。

有没有办法使这项工作?

4

0 回答 0