【发布时间】:2015-01-21 04:27:39
【问题描述】:
我想要一个获取一些信息然后写入本地文件系统的 rake 任务
我以为我有这个工作,但不知道如何。
namespace :arc do
task :vday => :environment do
locations=Location.with_current_mec "something"
jt={}
jt[:locations]={}
locations.each do |location|
jt[:locations][location.id]=location.to_small_hash
end
# want this to write to local filesytem
File.write('/Users/jt/output.json', JSON.pretty_generate(jt))
end
end
然后像这样调用
heroku run rake arc:vday
但这不起作用,并且在写入文件时出现错误。有没有办法让它写入我的本地文件系统而不是heroku?
【问题讨论】:
标签: ruby-on-rails heroku rake