How do I submit a text field and return to a new page?

Hello,

I know what I am trying to do is pretty basic but for a newbie like me
everything is very daunting right now. Please help me.

The scenario I am trying to program is this. The user enters a string in
the
search textfield. I will use his entered value to query the database for
a
matched record and then display the attributes of the fetched record.
That
is it.

Here is my controller that hopefully on submission from the UI will
retrieve
the data
===in controller route_controller.rb====
def display_route
s = params[‘route’][‘name’]
@searched_route = Route.find_by_name(s)
end

=====list.rhtml=================
<%= text_field_with_auto_complete :route, :name %>
=====end list.rhtml==============

I don’t have a view yet to display the queried result. The confusion is
because I am not sure how I should use the form_tag or form_for and also
how
to wrap it around the textfield that has autocomplete enabled above.
Another
dilemma I have is the fact that I would ideally like to hit enter in the
textfield to submit the form. But I am not sure if I want to use POST
since
I am getting stuff I should probably use a GET.

I am really confused and the ruby syntax is irritating when you are
learning
it. Please help me.

Thanks
Vijay

Hej Vijay,

You can find some pretty good info about your problem on the Rails API
site:

This will explain the syntax of the form_tag. I would stick with the
default settings (namely POST as the request verb) and just go ahead
(would look something like <% form_tag ‘/your_controller/
display_route’ do %>

You can also find some tutorials for beginners on the web or buy a
book (pdf).

Hope that helps,
Christoph