Rails 2 앱을 Rails 3.2.13으로 업그레이드했는데 캐싱을 사용하려고 할 때 문제가 있습니다. 캐싱은 Rails 2에서 작동했으며 동일한 버전의 Ruby - 1.8.7을 사용하고 있습니다. 관련성이 있는지는 잘 모르겠지만 OSX에서 개발 중입니다.expire_fragment를 호출하면 #url_for를 사용하기 위해 명시 적으로 라우팅 도우미를 포함해야합니다. 오류
expire_fragment가 호출 될 때 ActionController :: Caching :: Fragments 클래스에서 오류가 발생합니다. expire_fragment을 포함하는 fragment_cache_key하는 호출을이 :
ActiveSupport::Cache.expand_cache_key(key.is_a?(Hash) ? url_for(key).split("://").last : key, :views)
이 조금 더 확장 역 추적입니다
2013-07-10T14:40:50.430137+01:00 FATAL
RuntimeError (In order to use #url_for, you must include routing helpers explicitly. For instance, `include Rails.application.routes.url_helpers):
lib/bio_catalogue/cache_helper.rb:175:in `expire_fragment'
lib/bio_catalogue/cache_helper.rb:181:in `expire_service_index_tag_cloud'
app/observers/annotation_observer.rb:33:in `expire_caches'
app/observers/annotation_observer.rb:12:in `after_create'
app/controllers/annotations_controller.rb:140:in `create_inline'
이 오류를 제기한다 url_for하는이 호출 : 당연히
freya.2235 actionpack (3.2.13) lib/abstract_controller/url_for.rb:14:in `_routes'
freya.2235 actionpack (3.2.13) lib/action_dispatch/routing/url_for.rb:148:in `url_=
freya.2235 for'
freya.2235 actionpack (3.2.13) lib/action_controller/caching/fragments.rb:53:in `f=
freya.2235 ragment_cache_key'
freya.2235 actionpack (3.2.13) lib/action_controller/caching/fragments.rb:112:in `=
freya.2235 expire_fragment'
freya.2235 lib/bio_catalogue/cache_helper.rb:175:in `expire_fragment'
freya.2235 lib/bio_catalogue/cache_helper.rb:181:in `expire_service_index_tag_clou=
freya.2235 d'
freya.2235 app/observers/annotation_observer.rb:33:in `expire_caches'
freya.2235 app/observers/annotation_observer.rb:12:in `after_create'
freya.2235 activemodel (3.2.13) lib/active_model/observing.rb:231:in `send'
freya.2235 activemodel (3.2.13) lib/active_model/observing.rb:231:in `update'
freya.2235 activerecord (3.2.13) lib/active_record/observer.rb:114:in `_notify_ann=
freya.2235 otation_observer_for_after_create'
나는 expire_fragment를 호출하는 클래스에 Rails.application.routes.url_helpers를 포함하려고 시도했지만, ActionController 모듈 내에서 오류가 발생하면 아무 소용이 없습니다. ActionController :: Base에는 이미 UrlFor 모듈이 포함되어 있으므로 제 질문은 입니다. UrlFor를 포함하는 모듈의 클래스가 url_for를 잘 사용할 수 있어야 할 때 url_helpers를 포함하라는 오류를 발생시키는 이유는 무엇입니까?
expire_fragment로 전송하기 전에 조각을 찾기 위해 url_for를 찾아 해결 방법을 찾았습니다. 예 : @ controller.expire_fragment (key, options) to @ controller.expire_fragment (Rails.application.routes.url_helpers.url_for (key.merge ({: only_path => true})) 옵션) – Njall