The Rails command rails dev:cache
toggles whether Rails caching features work in the local development environment. It does this by creating or destroying a file that acts as a flag for the features. However, for our dev setup script, I would like to run the command so that the caching features are always turned on instead of toggled.
The source code for rails dev:cache
includes this enable_by_argument
function:
def enable_by_argument(caching)
FileUtils.mkdir_p("tmp")
if caching
create_cache_file
elsif caching == false && File.exist?(FILE)
delete_cache_file
end
end
How do I run the rails dev:cache
command so that it uses this argument? I've tried several variations, including rails dev:cache[true]
, rails dev:cache\[true\]
and rails dev:cache true
, but all of them have used the toggling behavior instead of the argument-controlled behavior.
This is not a duplicate of How to pass command line arguments to a rake task because that question is about passing arguments to Rake tasks. But this is a command built into Rails instead.