調子はどう?
私の友人は、データベース内のデータを更新するために rake タスクを作成しました (db の変更があるため)。タスクは次のとおりです。
namespace :db do
task :update_database => :environment do
puts "Update do banco"
posts = Post.where("source_id is null").order("id")
done = Array.new
posts.each do |post|
if post.source_id.nil? and !done.include?(post)
posts2 = Post.where("content LIKE ? AND id != ?", post.content, post.id)
done.concat(posts2)
posts2.each do |post2|
post2.source_id = post.id
post2.save
end
end
end
end
end
ローカルホストでこの rake タスクを既に実行しましたが、プロジェクトを heroku にデプロイすると、プロジェクトがオンラインで開きません。rake タスクを実行するコマンドを覚えていません。どこにも見つかりません。
私の質問は次のとおりです。
- rake タスクを実行するコマンドは何ですか?
- herokuでrakeタスクを実行するコマンドは何ですか? 「heroku run」だけ?
ありがとう!