【发布时间】:2021-12-02 23:08:25
【问题描述】:
我尝试在模型类中直接使用 ActiveSupport::Cache::FileStore:
@backend_cache = ActiveSupport::Cache::FileCache.new Rails.root.join("tmp", "cache")
程序报告一个 NameError
NameError: uninitialized constant ActiveSupport::Cache::FileCache
Did you mean? FileTest
我加了
require "active_support"
require "active_support/core_ext"
它仍然显示错误。我知道我可以使用 Rails.Cache 达到目的,但是我缓存的对象必须在磁盘上,这与应用程序的其他部分不同。
应用程序是用 Rails 6 编写的。
【问题讨论】:
-
我认为你有一个错字:
::FileStore.new而不是FileCache
标签: ruby-on-rails