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

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
box:

  1. <% form_tag({:action => “search”}, :method => “get”) do %>
  2.   <label for="home_search">Keywords:</label>
    
  3.   <%= text_field_tag "q", params[:q] %>
    
  4.   <input type="submit" value="Search"/>
    
  • <%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%>  <%=i.description%>
    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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

    | Privacy Policy | Terms of Service | Remote Ruby Jobs