Fernando
Fernando

Reputation: 4629

Where to configure Rails 3 cache_store?

I'm trying to configure Rails 3 cache_store with something like this in environments/development.rb:

config.cache_store = :memory_store, {:size => 64.megabytes, :expires_in => 5.minutes}

But when i start server i get:

undefined method `megabytes' for 64:Fixnum (NoMethodError)

Probably something is not loaded yet.

My question is: where is the right place to configure it them? Where should i place this code?

Upvotes: 5

Views: 2636

Answers (2)

jang00
jang00

Reputation: 316

Or else add this line

require 'active_support/core_ext/numeric/bytes'

before

config.cache_store = :memory_store, {:size => 64.megabytes, :expires_in => 5.minutes}

Upvotes: 16

Nick Colgan
Nick Colgan

Reputation: 5508

Use ActionController::Base.cache_store = and place in an initializer file (create an rb file in config/initializers)

Upvotes: 1

Related Questions