在哪里配置Rails 3 cache_store?

Fer*_*ndo 5 ruby-on-rails-3

我正在尝试在环境/ development.rb中使用类似的东西配置Rails 3 cache_store:

config.cache_store = :memory_store, {:size => 64.megabytes, :expires_in => 5.minutes}
Run Code Online (Sandbox Code Playgroud)

但当我启动服务器时,我得到:

undefined method `megabytes' for 64:Fixnum (NoMethodError)
Run Code Online (Sandbox Code Playgroud)

可能还没有加载某些东西.

我的问题是:在哪里配置它们的正确位置?我应该在哪里放置此代码?

小智 15

或者添加此行

require 'active_support/core_ext/numeric/bytes'
Run Code Online (Sandbox Code Playgroud)

之前

config.cache_store = :memory_store, {:size => 64.megabytes, :expires_in => 5.minutes}
Run Code Online (Sandbox Code Playgroud)


Nic*_*gan 1

使用ActionController::Base.cache_store =并放置在初始化文件中(在 config/initializers 中创建 rb 文件)