ruby on rails - will_paginate with include re-ordering results -
rails 2.3.8 + will_paginate 2.3.14
i have both product , productreview models.
product
has_many :product_reviews, :dependent => :destroy named_scope :most_recently_reviewed, :order => 'product_reviews.created_at desc', :include => [:product_reviews] productreview
belongs_to :product, :counter_cache => true running basic query , without pagination returns items in different order.
product.most_recently_reviewed.collect{|p| p.id }[0,9] => [1660, 1658, 2374, 578, 1595, 135, 531, 550, 1511] product.most_recently_reviewed.paginate(:page => 1, :per_page => 40).collect{|p| p.id }[0,9] => [1660, 2374, 578, 1711, 1855, 1730, 1668, 1654, 2198] expanding per_page number greater number of products causes paginate return proper results:
product.most_recently_reviewed.paginate(:page => 1, :per_page => 1000).collect{|p| p.id }[0,9] => [1660, 1658, 2374, 578, 1595, 135, 531, 550, 1511] any suggestions? thanks.
probably limit pagination being applied results of join, rows multiplicity of number of product reviews. haven't found better solution problem other moving scope criteria pagination call (you can move pagination call named scope). named scopes don't seem work will_paginate.
Comments
Post a Comment