加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

html – Rails form_tag没有显示

发布时间:2020-12-14 18:45:31 所属栏目:资源 来源:网络整理
导读:我正在按照这个简单的教程 http://railscasts.com/episodes/37-simple-search-form 这看起来很棒但是,我的表格标签似乎不起作用.这是我的HTML代码! 表单标签甚至都没有显示出来. h1Listing applications/h1% form_tag applications_path do % p %= text_fie
我正在按照这个简单的教程 http://railscasts.com/episodes/37-simple-search-form
这看起来很棒但是,我的表格标签似乎不起作用.这是我的HTML代码!
表单标签甚至都没有显示出来.
<h1>Listing applications</h1>

<% form_tag applications_path do %>
    <p>
        <%= text_field_tag :search %>
        <%= submit_tag "Search" %>
    </p>
<% end %>

<table>
  <tr>
    <th>Name</th>
    <th>Enviroment</th>
    <th>Applicationurl</th>
    <th>Server</th>
    <th>Additional Servers</th>
    <th></th>
    <th></th>
    <th></th>
  </tr>

<% @applications.each do |application| %>
  <tr>
    <td><%= application.name %></td>
    <td><%= application.date %></td>
    <td><%= application.size %></td>
    <td><%= application.author %></td>
    <td><%= application.addi_servers %></td>
    <td><%= link_to 'Show',application %></td>
    <td><%= link_to 'Edit',edit_application_path(application) %></td>
    <td><%= link_to 'Destroy',application,confirm: 'Are you sure?',method: :delete %></td>
  </tr>
<% end %>
</table>

<br />

<%= link_to 'New Application',new_application_path %>

我只有一个模型,“应用程序”

解决方法

根据 guide,你需要a = before form_tag
<%= form_tag("/search",:method => "get") do %>
  <%= label_tag(:q,"Search for:") %>
  <%= text_field_tag(:q) %>
  <%= submit_tag("Search") %>
<% end %>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读