我在new.html.erb上使用下面的代码,然后在视图页面上显示文本字段和“搜索”按钮:
<table>
<tr>
<td align="center">
<%= text_field :tf_Company,placeholder: "Company" %>
</td>
</tr>
</table>
<table>
<tr>
<td>
<div class="button">
<%= button_to "Search", {}, { :class => "buttonSearch"} %>
</div>
</td>
</tr>
</table>
但是当我在new.html.erb上添加form_for(:search)
时,如下所示:
<% form_for(:search) do |f| %>
<table>
<tr>
<td align="center">
<%= f.text_field :tf_Company,placeholder: "Company" %>
</td>
</tr>
</table>
<table>
<tr>
<td>
<div class="button">
<%= f.submit "Search", { :class => "buttonSearch"} %>
</div>
</td>
</tr>
</table>
<% end %>
然后它不会在视图页面上显示文本字段和按钮,请建议我在哪里弄错, 等待你的回复。感谢
答案 0 :(得分:1)
<%= form_for(:search) do |f| %>
你缺少=在form_for
之前