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. <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%> <%=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?
on 2008-08-12 21:18
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.