# Problem with search results

**URL:** <https://www.ruby-forum.com/t/problem-with-search-results/120264>\
**Category:** Ferret\
**Created:** [November 15, 2007, 12:05pm UTC](https://www.ruby-forum.com/t/problem-with-search-results/120264 "2007-11-15T12:05:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![katsuo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/ecc23a/32.png) [@katsuo](https://www.ruby-forum.com/u/katsuo)\
**Post date:** [November 15, 2007, 12:05pm UTC](https://www.ruby-forum.com/t/problem-with-search-results/120264/1 "2007-11-15T12:05:11Z")

</div>

Hi, I am trying to search ‘name’ column in ‘Title’ table with the  
following script. When I search using names, it returns zero result.  
However, when I enter id number of a field, it returns a result. Can  
anyone tell me what I am doing wrong?

class Title  
acts\_as\_ferret :fields =\> [:name]

class CatalogController  
def search  
@page\_title = “search”  
if params[:commit] == “Search” || params[:q]  
@titles = Title.find\_by\_contents(params[:q].to\_s.upcase)  
unless @titles.size \> 0  
flash.now[:notice] = “No titles find matching your criteria”  
end  
end  
end

#search.rhtml  
\<% if @titles %\>

Your search "\<%= params[:q] %\>" produced \<%= pluralize @titles.size, "result" %\>:

\<%= render(:partial =\> "titles") %\> \<% end %\>
