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 Guerra