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:
- <% form_tag({:action => “search”}, :method => “get”) do %>
-
<label for="home_search">Keywords:</label>
<%= text_field_tag "q", params[:q] %>
<input type="submit" value="Search"/>
- <%end%>
And then in the controller for Search action I have:
- def search
- if params[:q]
-
query = params[:q]
-
@results = Ad.find_by_contents(query, :limit => :all)
- end
- end
And then in the search view I have this:
- <% @results.each do |i| %>
- <%=i.title%> <%=i.description%>
- <%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?