把这加到 Rakefile 里。然后执行 rake loop
可自己定义每个指令需要重读的脚本
这样一些常用的指令就不用每次都等老半天啦~~~~
task :loop => [:environment] do
def reload_file(path)
File.exists?(path)
File.readlines(path).map do |line|
Dir[line]
end.flatten.each do |file|
load file
end
end
# specify the file paths you want to reload in the reload_file.
# each line is a Dir glob. e.g.
# config/routes.rb
# app/models/*.rb
reload_file = "reload"
loop do
reload_file reload_file
print "rake command:"
task = $stdin.readline.strip
Rake::Task[task].reenable
Rake::Task[task].invoke
end
end