Hi Kim
Take a lot at activescaffold where pagination is taken of pretty
nicely.
On Oct 18, 10:22 am, Kim Chirnside
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> I have run into some problems with the Rails paginate helper. Given a
> relatively complex pagination search including joins etc, the
> @item_count is set incorrectly. This is because the
> paginator_and_collection_for uses model.count with does not accept a
> SELECT DISTINCT query.
>
> I have made a small change to paginator_and_collection_for to allow a
> custom query for counting. The new version is:
>
> def paginator_and_collection_for(collection_id, options) #:nodoc:
> klass = options[:class_name].constantize
> page = params[options[:parameter]]
> unless options[:custom_search].nil?
> count = eval(options[:custom_search])
> else
> count = count_collection_for_pagination(klass, options)
> end
> paginator = Paginator.new(self, count, options[:per_page], page)
> collection = find_collection_for_pagination(klass, options,
> paginator)
>
> return paginator, collection
> end
>
> I have also changed the DEFAULT_OPTIONS to support the :custom_search
> option.
>
> My question is, how to make this change within my app, to overload the
> existing rails implementation. I understand that it is very bad form to
> modify the rails source on my machine, so am looking for a tidy
> alternative.
>
> Does anyone have examples of overloading methods of modules such as
> Pagination?
>
> Kim
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---