Reputation: 973
For an AR query like this:
@users = User.find(some_conditions_here)
then @users is an AR array and I want to cache this.
If I do, in one controller call, a
Rails.cache.write('foo',@users)
it doesn't complain or error out and I can even see a 'foo' under /tmp/cache with a non-zero size but a subsequent controller call to
Rails.cache.read('foo')
returns a nil. When I do both the write and read from a Rails console, it works as expected. What is it about doing it via a controller that causes this problem?
This used to work before in Rails 2... what am I missing?
Upvotes: 0
Views: 360
Reputation: 20895
Check that config.action_controller.perform_caching
is set to true
.
To quote the Rails caching guide,
caching is disabled by default for development and test, and enabled for production
Upvotes: 2