Upon following the instructions to create a rake task to clear the cache, when running that rake task:
namespace :cache do desc "Clears Rails cache" task :clear do Rails.cache.clear end end and running that rake task with:
rake cache:clear I get an error:
undefined method `clear' for nil:NilClass When running Rails.cache.clear from the rails console, it successfully clears the cache without an error. Why is cache nil on the Rails object in the rake task, but not in the rails console?
Note: I am using dalli and memcache.