How to use Action caching?
How to expire the action caching in the model?
My controller app/controllers/normal_reservation_controller.rb
class NormalReservationsController < ApplicationController
cache_sweeper: normal_reservation_sweeper
caches_action :index
def index
#code
end
end
My Sweeper app/sweepers/normal_reservation_sweeper.rb
class NormalReservationSweeper < ActionController::Caching::Sweeper
observe NormalReservation
def after_create(reservation)
expire_index_reservation
enddef after_destroy(reservation)
expire_index_reservation
enddef after_update(reservation)
expire_index_reservation
endprivate
def expire_index(reservation)
expire_action(:controller => ‘normal_reservations’, :action => ‘index’)
end
end
but I am getting an error like this
Thanks!!