Haml表单标签在Rails 3上没有包含任何内容 [英] The Haml form tag includes nothing on Rails 3

查看:102
本文介绍了Haml表单标签在Rails 3上没有包含任何内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为Haml可能存在一个错误?或者我错过了
这个form标签应该包含input元素,但它不会。

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>...

我期望它是

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

这是我的haml文件,迭代数组中的每个任务,

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"


推荐答案

一个简单的标记是 button_to link_to 。 UJS会将它们转换为 remote:true 方法:: delete 以自动生成。所以

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

这篇关于Haml表单标签在Rails 3上没有包含任何内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆