# How do I pass query from from to the controller?

**URL:** <https://www.ruby-forum.com/t/how-do-i-pass-query-from-from-to-the-controller/102212>\
**Category:** Rails\
**Created:** [August 12, 2006, 11:47pm UTC](https://www.ruby-forum.com/t/how-do-i-pass-query-from-from-to-the-controller/102212 "2006-08-12T23:47:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidstokar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/4da419/32.png) [@davidstokar](https://www.ruby-forum.com/u/davidstokar)\
**Post date:** [August 12, 2006, 11:47pm UTC](https://www.ruby-forum.com/t/how-do-i-pass-query-from-from-to-the-controller/102212/1 "2006-08-12T23:47:08Z")

</div>

Hi

I need to pass a query string for a search to a controller from the  
view.

View:  
\<%= start\_form\_tag(:action =\> ‘get\_results’) %\>  
\<%= text\_field ‘search’, ‘search\_term’ %\>  
\<%= submit\_tag “Search” %\>  
\<%= end\_form\_tag %\>

Controller:  
def get\_results(query)  
@results = Advert.find(:all,  
:conditions =\> “title = ‘#{query}’ OR  
description ‘#{query}’”,  
:order =\> “created\_at DESC”)  
return @results  
end

What do I need to add to the view?

Thanks,

David
