有没有办法使我的自定义rake任务只在development环境中列出,而不是在production和QA中列出?
我的意思是,当我在qa或production env中调用production时,它不应该列出我的自定义rake tasks,而应该在development中列出。
发布于 2015-08-06 12:57:31
您可以将其添加到应用程序Rakefile (MyRailsApp::Application.load_tasks行之后):
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) }
endhttps://stackoverflow.com/questions/31855366
复制相似问题