actionpack-action_caching icon indicating copy to clipboard operation
actionpack-action_caching copied to clipboard

expiring an action cache

Open mzaragoza opened this issue 8 years ago • 4 comments

I added this to my project and its working fine but I am having a problem expiring the cache

my controller looks like

class PostsController < ApplicationController
  caches_action :show

   def show 
     @post = Post.find(params[:id])
   end
end

it works fine when I visit different post but when a post gets updated it does not reflect that

Thanks

mzaragoza avatar Oct 14 '17 16:10 mzaragoza

@mzaragoza you are right, the documentation of this gem is not complete. You have to use a so called Sweeper.

Have a look at the rails-observers README.

zedtux avatar Nov 16 '17 10:11 zedtux

Можно обновлять так: expire_action controller: "posts", action: "show" Но данный метод не работает из другого контроллера! Может кто подскажет как его вызвать из другого контроллера?

andreevmap avatar Jan 15 '19 19:01 andreevmap

@zedtux rails-observers is not working for rails 5.. end mongoid

andreevmap avatar Jan 15 '19 19:01 andreevmap

:+1: It would be nice to have a cache_key type of control over the expiration of the cache at the controller level.

vanboom avatar Apr 29 '21 15:04 vanboom