ubuntu, ror, jQuery, css, website memo
太嫩, 沒啥心得, 用來紀錄每天學的
2009年12月3日 星期四
Paginating with the Fragment Cache
Paginating with the Fragment Cache
# Cache Controller
def count
unless read_fragment({:page => params[:page] || 1})
@recommends = Recommend.paginate(:all , :group => 'stock' , :select => 'stock,count(id) as count' , :order => 'count(id) DESC' , :page => params[:page] , :per_page => 8)
end
end
def expire
expire_fragment(%r{cache/count.*})
end
# View count.html.erb
<% cache({:page => params[:page] || 1}) do %>
//View HTML
<% end %>
Another notable way we can clear out not only our Action Cache and Fragment cache is to run the following rake task:
rake tmp:cache:clear
沒有留言:
張貼留言
較新的文章
較舊的文章
首頁
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言