Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这个问题的反面:仅为 Rake 任务运行初始化程序
是否可以在 rake 任务期间排除初始化程序?
谢谢。
您可以将初始化程序包装在这样的块中:
unless ( File.basename($0) == 'rake') # Initializer code end
直接来自这个答案:https ://stackoverflow.com/a/24159563/1867481