Well, since you're doing search you might want to look at ferret and
acts_as_ferret.  It creates an index file for searching and you can
use methods to generate index fields.  As a bonus it's really fast and
has nice powerful search syntax.  It did take a little work getting
pagination going with it.

If you do use it, here's the code I used to get pagination going:

lib/ferret_pagination.rb (required in environment.rb)
module ActsAsFerret
  module ClassMethods
    def paginate_search(query, options = {}, find_options = {})
      page     = options[:page] || 1
      per_page = options[:per_page] || 10
      total    = options[:total_entries]

      pager = WillPaginate::Collection.new(page, per_page, total)
      options.merge!(:offset => pager.offset, :limit => per_page)
      result = find_by_contents(query, options, find_options)
      returning WillPaginate::Collection.new(page, per_page,
result.total_hits) do |p|
        p.replace result
      end
    end
  end
end

And here's an example modified index method:

def index
    conditions = 'publication_id IS NULL'
    query = params[:search].blank? ? '*' : params[:search]
    @letters = Letter.paginate_search(
          query,
          {:page => (params[:page] or 1),
          :per_page => (current_user.try.per_page or 10) },
          {:conditions => conditions} )
    @letters.member_class = Letter
end

On Jun 24, 9:26 am, hobo_hippy <[email protected]> wrote:
> I have a bad reason. I was looking for a workaround to this problem:
>
> http://groups.google.com/group/hobousers/browse_thread/thread/85ed39a...
>
> go to the last reply I posted at: Jun 24, 10:19 am
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to