[Rails] Re: Fragment caching and pagination
Steve Odom
steve.odom at gmail.com
Wed Feb 1 11:36:53 GMT 2006
Excellent. Just what I was looking for.
Steve
On 2/1/06, Alain Ravet <arav2132 at biz.tiscali.be> wrote:
>
> Steve
> >.. how is pagination and query strings handled with fragment
> caching?
> > Does each page get its own fragment and query string identifier?
>
> Yes. Each page related fragment is cached separately.
>
> Here is what works for me:
>
>
> In the view: (event/list.rhtml, a paginated view, with an optional
> 'year' filter. )
>
> line 1: <% cache(:controller => 'event', :action => 'list', :group
> => visitor.group, :page => params[:page], :year => params[:year]) do%>
> ...
>
> In the Controller:
> class EventController < ApplicationController
> cache_sweeper :event_sweeper, :only => [:edit, :update, :new,
> :create, :destroy]
> ...
>
> In the sweeper:
> class EventSweeper < ActionController::Caching::BaseSweeper
> observe Event
>
> def after_save(record)
> expire_fragment %r{event/list.*}
> expire_home_page
> end
> def after_destroy(record)
> expire_fragment %r{event/list.*}
> expire_home_page
> end
>
> end
>
>
> _______________________________________________
> Rails mailing list
> Rails at lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060201/0c24bb5f/attachment-0001.html
More information about the Rails
mailing list