Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Enhanced paginate method to sort by id by default #342

Closed
wants to merge 1 commit into from

2 participants

@kalarani

This makes sure that there is a default ordering so that 'paginate' method doesn't fetch duplicate records for indexing. This commit fixes #272

@karmi
Owner

I suspect this to be ActiveRecord specific? We need to support generic ActiveModels OxMs... Will close this unless you have a generic solution, OK?

@karmi
Owner

Closing, ActiveRecord specific code.

@karmi karmi closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 12, 2012
  1. @kalarani

    #272 | Kala | Added 'order_by_id' to the paginate method to fix rando…

    kalarani authored
    …m ordering of records while indexing
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/tire/tasks.rb
View
2  lib/tire/tasks.rb
@@ -73,7 +73,7 @@ def elapsed_to_human(elapsed)
if defined?(Kaminari) && klass.respond_to?(:page)
klass.instance_eval do
def paginate(options = {})
- page(options[:page]).per(options[:per_page]).to_a
+ order("#{klass.table_name}.id").page(options[:page]).per(options[:per_page]).to_a
end
end
end unless klass.respond_to?(:paginate)
Something went wrong with that request. Please try again.