# Act\_as\_ferret multi\_search

**URL:** <https://www.ruby-forum.com/t/act-as-ferret-multi-search/123959>\
**Category:** Rails\
**Created:** [December 22, 2007, 5:53pm UTC](https://www.ruby-forum.com/t/act-as-ferret-multi-search/123959 "2007-12-22T17:53:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thiago\_G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@Thiago\_G](https://www.ruby-forum.com/u/Thiago_G)\
**Post date:** [December 22, 2007, 5:53pm UTC](https://www.ruby-forum.com/t/act-as-ferret-multi-search/123959/1 "2007-12-22T17:53:42Z")

</div>

Hi everyone,

I’m trying to use act\_as\_ferret multi\_search with paginating\_links  
plugin but I’m getting a undefined method for multi\_search which is a  
act\_as\_ferret method that I’ve been using a lot in my app. I just  
can’t see what I’m doing wrong and I’m sure it is just a little  
detail.

Here is my code:

############# This is my class method

def paginating\_ferret\_multi\_search(models, options)  
count = multi\_search(options[:q], {:limit =\> :all, :lazy  
=\> true}, models).total\_hits

```
   PagingEnumerator.new(options[:page_size], count, false,

```

options[:current], 1) do |page|  
offset = (options[:current].to\_i - 1) \*  
options[:page\_size]  
limit = options[:page\_size]  
multi\_search(models, options[:q], {:offset =\>  
offset, :limit =\> limit})  
end  
end

########### This is how I’m calling it in my controller:

def search  
@title = “aykall - search”  
if params[:q]  
query = sanitize(params[:q])  
begin  
@users = User.paginating\_ferret\_multi\_search([Spec, Faq],  
{:q =\> query, :page\_size =\> 10, :current =\> params[:p]})  
@users = @users.sort\_by { |user| user.spec.last\_name }  
rescue Ferret::QueryParser::QueryParseException  
flash[:notice] = “Invalid character in search”  
end  
end  
end

######## the error I’m getting is: undefined method `multi\_search’ for  
User:Class

########## when I use self. on my classmethod i get a undefined method  
`paginating\_ferret\_multi\_search’ for User:Class

def self.paginating\_ferret\_multi\_search(models, options)  
count = self.multi\_search(options[:q], {:limit =\> :all, :lazy =\>  
true}, models).total\_hits

```
   PagingEnumerator.new(options[:page_size], count, false,

```

options[:current], 1) do |page|  
offset = (options[:current].to\_i - 1) \* options[:page\_size]  
limit = options[:page\_size]  
self.multi\_search(models, options[:q], {:offset =\>  
offset, :limit =\> limit})  
end  
end

I don’t know what else to try…

Hope some one can help me around here…

Thanks,  
Thiago G.

---

<div class="post-metadata">

**Author:** ![Thiago\_G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@Thiago\_G](https://www.ruby-forum.com/u/Thiago_G)\
**Post date:** [February 4, 2008, 5:29pm UTC](https://www.ruby-forum.com/t/act-as-ferret-multi-search/123959/2 "2008-02-04T17:29:53Z")

</div>

Have you had any luck figuring this one out? I’m having the same  
problem.
