2012-08-24 14 views
6

Ich bin dieses einfache Tutorial http://railscasts.com/episodes/37-simple-search-form , die scheint toll zu sein, aber mein Formular Tag scheint nicht zu funktionieren. Hier ist mein HTML-Code! Das Formular-Tag wird nicht angezeigt.Rails form_tag nicht angezeigt

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

Und ich habe nur ein Modell, "Application"

Antwort

19

Nach dem guide Sie benötigen ein = vor form_tag

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

das Video nicht ein '=' –

+2

enthalten habe ich denke, vielleicht Ältere Rails-Versionen brauchten das nicht für Formular-Tags? – Dty

+1

Die Ruby on Rails Guides zu Rails Form Helpers fehlt das "=" –

Verwandte Themen