I’m wondering if there
was a better way to do this:
I want to add a prerequisite check to the db:reset rails task so that
if we’re in production mode, the user has to add an additional
environment variable for it to run (yes, I know users shouldn’t even
be on production machines, but in this case it’s worth it).
What I found I had to do was:
- added a task for the check:
namespace :fp do
task :check_for_production_flag => :environment do
raise "Boom!" unless RAILS_ENV!='production' ||
- added a dependency for db:reset:
namespace :db do
task :reset => [“fp:check_for_production_flag”]
And then, most importantly, had to change Rakefile so that the rake
file with the above items was loaded before “require ‘tasks/rails’”.
This may be because db:reset is actually an empty task and
accomplishes its work through its 3 prerequisites.
Did I have any alternative to doing it this way?