Reputation: 175
I have this code on _search_boxes.html.erb
<%= form_tag({:action => "search"}, {:method => "get"}) %>
<%= text_field_tag :q %>
<%= submit_tag "Search" %>
<%= end_form_tag %>
but the last line shows that undefined local variable or method `end_form_tag' error
Upvotes: 0
Views: 1114
Reputation: 162
The proper code should look like this:
<%= form_tag({:action => "search"}, {:method => "get"}) do %>
<%= text_field_tag :q %>
<%= submit_tag "Search" %>
<% end %>
You shouldn't need an =
in the <%= end %>
the only times you use =
would be when you have some ruby code to show in the application. Hope this helps!
Upvotes: 0
Reputation: 33542
<%end_form_tag %>
works with Rails versions prior 3 and now it is deprecated.Instead use <%end%>
or even just using </form>
will also works.
So your should looks like this
<%= form_tag({:action => "search"}, {:method => "get"}) %>
<%= text_field_tag :q %>
<%= submit_tag "Search" %>
<% end %>
Update
you are missing a do
in your form_tag
and remove =
in <%= end %>
.It should be like this
<%= form_tag({:action => "search"}, {:method => "get"}) do %>
<%= text_field_tag :q %>
<%= submit_tag "Search" %>
<% end %>
For more details,see this API
Upvotes: 2
Reputation: 4053
<%= form_tag('/search', method: :get) do -%>
<%= text_field_tag 'q' %>
<%= submit_tag 'Save' %>
<% end -%>
for more information refer ruby-doc
Upvotes: 1
Reputation: 76774
Just use <% end %>
instead of <% end_form_tag %>
.<% end_form_tag %>
is now deprecated.
Upvotes: 0
Reputation: 914
<%= end_form_tag %>
is deprecated.
Just use
<%= form_tag({:action => "search"}, {:method => "get"}) %>
<%= text_field_tag :q %>
<%= submit_tag "Search" %>
<%= end %>
Upvotes: 0