该Haml的表单标签包括on Rails的什么3(The Haml form tag include

2019-10-18 22:32发布

我认为有可能是一个错误的Haml的? 什么我错过了应该来包围输入元素的表单标签,但事实并非如此。

<form accept-charset="UTF-8" action="/remote_focus/kill_running_task" data-remote="true" method="get"></form>
            <tr>
              <td>...

在那里我希望它是

<form accept-charset="UTF-8" action="/remote_focus/kill_running_task" data-remote="true" method="get">
                <tr>
                  <td>...
</form>

这是我的HAML文件,从一个数组遍历每个任务,

  - @running_tasks.each do |running_task|        
    = form_tag kill_running_task_remote_focus_path, :method => :get, remote: true do
      %tr
        %td
          = running_task[:user]
        %td 
          = running_task[:ip]
        %td 
          = running_task[:time]
        %td 
          = running_task[:pid]
          = hidden_field_tag :task, running_task[:pid]
        %td
          = submit_tag "Kill This Task" ,:class=> "btn btn-primary autotest"

Answer 1:

除了形式,一个简单的标签是button_tolink_to 。 UJS将转变那些有remote: truemethod: :delete自动形成。 所以

// Remove the previous form_tag
%td
  = button_to kill_running_task_remote_focus_path, :method => :delete, remote: true


Answer 2:

尝试删除所有的TR TD,并让尝试一次。



文章来源: The Haml form tag includes nothing on Rails 3