Rails 3, will_paginate over existing limited active record result?

It looks like will_paginate imposes its own limit clause on your relation in order to do the paging. After some experimentation, the easiest way I could find to do this is to do eager-loading of the result set and use the functionality contained in the array extensions to do the actual pagination. Here's a quick example; note that you have to require will_paginate/array; you may wish to do this in an initializer or somewhere else.

Note that it does monkey-patch Array to have the paginate method. Require 'will_paginate/array' class ArticlesController params:page, :per_page => 10) end end Update Another option is to pass in the total_entires option to will_paginate based on the result set size. Class ArticlesController params:page, :per_page => 10, :total_entries => @articles.

Count) end end You can't pass in 20 as you can't guarantee that a full 20 results will be returned; by passing in the count attribute, you can ensure that the pagination will be correct.

Ty brandon works like a charm, that was what I was searching for – hereandnow78 Nov 20 at 20:54.

It looks like will_paginate imposes its own limit clause on your relation in order to do the paging. After some experimentation, the easiest way I could find to do this is to do eager-loading of the result set and use the functionality contained in the array extensions to do the actual pagination.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions