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

**URL:** <https://www.ruby-forum.com/t/how-do-i-submit-a-text-field-and-return-to-a-new-page/121268>\
**Category:** Rails\
**Created:** [November 26, 2007, 10:35am UTC](https://www.ruby-forum.com/t/how-do-i-submit-a-text-field-and-return-to-a-new-page/121268 "2007-11-26T10:35:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vijay\_Rao](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/c77e96/32.png) [@Vijay\_Rao](https://www.ruby-forum.com/u/Vijay_Rao)\
**Post date:** [November 26, 2007, 10:35am UTC](https://www.ruby-forum.com/t/how-do-i-submit-a-text-field-and-return-to-a-new-page/121268/1 "2007-11-26T10:35:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Vijay\_Rao](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/c77e96/32.png) [@Vijay\_Rao](https://www.ruby-forum.com/u/Vijay_Rao)\
**Post date:** [November 26, 2007, 1:25pm UTC](https://www.ruby-forum.com/t/how-do-i-submit-a-text-field-and-return-to-a-new-page/121268/2 "2007-11-26T13:25:10Z")

</div>

Hej Vijay,

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

> **[ActionView::Helpers::FormTagHelper](https://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#M000607)**
>
> Provides a number of methods for creating form tags that don't rely on an Active Record object assigned to the template like FormHelper does. Instead, you provide the names and values manually.

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
