Is there any way to make my custom rake tasks only listed in development
environment but not in production
and QA
?
I mean, when I invoke bundle exec rake -T
in qa
or production
env, it should not list my custom rake tasks
but it should in development
.
You can add this to the application Rakefile
(after MyRailsApp::Application.load_tasks
line):
if Rails.env == "production"
# add here the tasks you want to disable
tasks_to_disable = [
"db:drop",
"db:reset"
]
tasks = Rake.application.instance_variable_get("@tasks")
tasks.delete_if { |task_name, _| tasks_to_disable.include?(task_name) }
end