Today i am trying to present the items from a list that were paginated:
users = User.order('name').paginate(:per_page => 10, :page => 1).map{|u| UserPresenter.new(e)}
The problem is that users is no longer (after mapping to my presenter) an array wrapped with will_paginate magic, so it does not contains such things like total_entries, per_page or page, then the will_paginate helper is not working in my view :S .
How should i proceed to paginate a list of post-processed objects?
I've tried doing the other way around but then if i have a huge amount of records in my table it will be really painful because it will paginate from a big result set that is already retrieved:
users = User.order('name').map{|u| UserPresenter.new(u)}.paginate(:per_page => 10, :page => 1)
Thanks in advance
I would suggest that you still use users
for will_paginate
and add another instance variables for presenters.
@users = User.order('name').paginate(:per_page => 10, :page => 1)
@presenters = @users.map { |u| UserPresenter.new(u) }