How to use will_paginate with model caching in rails?
There is a region ( scope :short_listed, -> ....
) in my model . To list all the elements on the index page, I use this code:
@posts = Post.cached_short_listed.paginate(:page => params[:page])
post.rb
def self.cached_short_listed
Rails.cache.fetch([name, "short_listed"], expires_in: 5.minutes) do
short_listed.to_a
end
end
and i have this error
undefined method `paginate' for #<Array:
if i uninstall .paginate(:page => params[:page])
and <%= will_paginate....%>
everything works fine.
How to make will_paginate work with model caching.
+3
source to share