Forum: Ferret Ferret "works", but only returns 1 item for a query :(

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
01cb925280e8da9ab1b38896225ac4bd?d=identicon&s=25 Bob Gratton (bobgratton)
on 2008-08-12 21:18
m trying to set up up a basic search bar that will search a table called
ads. It as 3 fields, the ID, TITLE and DESCRIPTION.

I put "acts_as_ferret" in the Ad model. and this code for the search

   1. <% form_tag({:action => "search"}, :method => "get") do %>
   2.   <div>
   3.       <label for="home_search">Keywords:</label>
   4.       <%= text_field_tag "q", params[:q] %>
   5.       <input type="submit" value="Search"/>
   6.   </div>
   7. <%end%>

And then in the controller for Search action I have:

   1. def search
   2.    if params[:q]
   3.      query = params[:q]
   4.      @results = Ad.find_by_contents(query, :limit => :all)
   5.    end
   6. end

And then in the search view I have this:

   1. <% @results.each do |i| %>
   2.   <%=i.title%>&nbsp;&nbsp;<%=i.description%><br/>
   3. <%end%>

It kinda works, but it only returns one record for any keyword I try
when I know it should return more. I tried rebuilding the Ferret index
and it doesn't help sad.

Am I missing something?
This topic is locked and can not be replied to.