2012-08-24 71 views
6

我正在關注這個簡單的教程http://railscasts.com/episodes/37-simple-search-form 這似乎是偉大的,但我的表單標籤似乎並不工作。這是我的html代碼! 表單標籤甚至不顯示。Rails的form_tag沒有顯示

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

而且我只有一個模式,「應用程序」

回答

19

按照guide你需要一個=form_tag

<%= form_tag("/search", :method => "get") do %> 
    <%= label_tag(:q, "Search for:") %> 
    <%= text_field_tag(:q) %> 
    <%= submit_tag("Search") %> 
<% end %> 
+1

視頻不包括「=」 –

+2

我想,也許老版本的rails不需要它的形式標籤? – Dty

+1

Ruby on Rails Rails表單助手指南缺少「=」 –