Reputation: 19969
I would like a rake task that gets some information and then writes to the local filesytem
I thought I had this working but not sure how.
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
and then call like
heroku run rake arc:vday
But this is not working and gives me an error on writing the file. Is there a workaround to make it write to my local filesystem and not heroku?
Upvotes: 1
Views: 1754
Reputation: 1380
Can you try this
File.open('/Users/jt/output.json', 'w') {|file| file.write(JSON.pretty_generate(jt))}
instead of
File.write('/Users/jt/output.json', JSON.pretty_generate(jt))
Upvotes: 1