I have a scope in my model(scope :short_listed, -> ....
). To list all the items on 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 remove .paginate(:page => params[:page])
and <%= will_paginate....%>
everything works fine.
How to make will_paginate work with model caching.