Rails 3.0.19
アプリケーションにフラグメント キャッシュを実装しdalli
、キャッシュ ストアとして使用しようとしています。これが私のキャッシュフラグメントスクリプトです:
- @presentations.each do |p|
- cache "presentation", p do
= render_presentation_object p
render_presetnation_object
いくつかの条件に基づいて特定のパーシャルを実際にレンダリングします。また、コントローラーにスイーパーを追加しました。
cache_sweeper :presentation_sweeper, :only => [:create, :update, :destroy]
caches_action :update
スイーパーのコードは次のとおりです。
class PresentationSweeper < ActionController::Caching::Sweeper
observe Presentation
def after_save(presentation)
expire_cache(presentation)
end
def after_update(presentation)
expire_cache(presentation)
end
def after_destroy(presentation)
expire_cache(presentation)
end
def expire_cache(presentation)
expire_fragment "presentation", presentation
end
end
このコードを使用してコントローラーから何かを更新しようとすると@presentation.update_attributes(params[:presentation])
、エラーが発生しましたActiveRecord::StatementInvalid (RuntimeError: can't modify frozen object:
私が見逃しているものはありますか?