0

私はコントローラーを持っています:

caches_action :show
cache_sweeper :the_model_sweeper, :only => [:update, :destroy]

とスイーパー:

observe TheModel

def after_save(the_model)
  expire_cache(the_model)
end

def after_destroy(the_model)
  expire_cache(the_model)
end

def expire_cache(the_model)
  expire_action :controller => '/the_model', :action => 'show'
end

そして得ています:

ActionController::RoutingError (No route matches {:controller=>"/the_model", :action=>"show"}):

私が推測している問題は、スイーパーが after_save と呼ばれているためです。新しいレコードでは、更新または削除時にのみスイープするように具体的に言ったにもかかわらず、破棄するものは何もありません。

(例として、モデルの名前を明らかに「The Model」に変更しました)

4

1 に答える 1

0

この問題は、ActiveAdmin を使用していて、(doh...) :only => [:update, :destroy] をそのモデルのアクティブな管理構成に追加するのを忘れていたことが原因でした。

于 2012-10-19T12:43:30.010 に答える