On Tue, Apr 17, 2007 at 08:26:04PM +0200, Steven Garcia wrote:
> For clarification purposes, I am trying to return instances from  
> multiple models, meaning just one multi_search method for all. I am  
> convinced that I am not writing my Search Controller correctly. I am  
> trying to use full text search and pagination and have no idea how to
> 
> 1. hook into these various models in my controller action
> 2. call up the results in my view

First of all, the full_text_search methods in your model classes won't help 
you a thing since you aren't calling them. 

What you call is your multi_search call in the search model. So that's
where you have to implement the paging.

However if I were you I'd first try to get this working without
pagination. Once this works, all that's left is to implement pagination
across that set of results.

To deal with having different models in your @results array, build a
helper method to handle this:

module SearchHelper
  # might be extended to not only render the name of a record, but a
  # link to a details page, too. Always depending of the record's type,
  # of course.
  def search_result_name(result)
    case result
    when Term
      result.name
    when Article
      result.title
    else
      result.to_s
    end
  end
end

Now use that in your view:

<ul>
  <% @results.each do |result| %>
    <li><%= search_result_name result %></li>
  <% end %>
</ul>

For the pagination stuff you'll have to implement the page selection
that is done in the unused full_text_search methods in your search
model, should be easy to adapt since multi_search takes the same options
as find_by_contents.

Jens


-- 
Jens Krämer
webit! Gesellschaft für neue Medien mbH
Schnorrstraße 76 | 01069 Dresden
Telefon +49 351 46766-0 | Telefax +49 351 46766-66
[EMAIL PROTECTED] | www.webit.de
 
Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to