The Haml form tag includes nothing on Rails 3

霸气de小男生 提交于 2019-12-11 10:39:32

问题


I think there may be a bug in Haml? Or something I missed The form tag supposed to enclose the input element, but it doesn't.

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

Where I expect it is

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

This is my haml file, iterate each task from an array,

  - @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"

回答1:


Other than form, a simpler tag is button_to or link_to. UJS will convert those with remote: true and method: :delete to form automatically. So

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



回答2:


Try to remove all the tr td and lets try once.



来源:https://stackoverflow.com/questions/19851166/the-haml-form-tag-includes-nothing-on-rails-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!