如何使用分页缓存索引页?

时间:2014-07-03 06:32:52

标签: ruby caching ruby-on-rails-4 pagination activeadmin

假设这是我的管理模型

ActiveAdmin.register Theme do
  menu :if => proc{ current_admin_user.super_admin?}

  after_filter :only => [:create, :update, :destroy] do
    expire_action :action => :show
    expire_action :action => :index
  end

  controller do
    caches_action :index, :show
  end
end

使用此代码缓存已完成,但在带有分页的索引页面上我面临问题,即我无法访问主题的另一页。

如何实现这样的事情 https://github.com/amatsuda/kaminari#creating-friendly-urls-and-caching

1 个答案:

答案 0 :(得分:2)

这就解决了这个问题:

caches_action :index, :cache_path => Proc.new { |c| c.params }

这将为特定的paginate param的

生成新的缓存

Read More