Action caching with dynamic cache names

Hi,

I am attempting to cache a page that varies depending on the URL that
you go to. For example, http://mydomain.com/member_name goes to the
same action and controller as http://mydomain.com/other_member, but
the page is customized to the member.

I am currently accomplishing this with the following:

applications_controller.rb

caches_action :new, :cache_path => :new_cache_path.to_proc

private
def new_cache_path
params[:member_name]
end

This works fine, but I run into issues when I try and sweep the cache
because im am not sure how I can pass the member_name parameter to the
sweeper. The following is what I am using for a sweeper:

members_controller.rb

cache_sweeper :member_sweeper, :only => [ :update ]

class MemberSweeper < ActionController::Caching::Sweeper
observe Member

def after_save(product)
expire_cache(product)
end

def after_destroy(product)
expire_cache(product)
end

def expire_cache(product)
expire_action ‘member_name’
end
end

The members name is being passed to the member controller via the
submitted form, I just need to know if it is possible to pass it to
the sweeper.

Thanks for your help!

Ryan

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs