what's up?
My friend created a rake task to update our data in the database (because we have db changes). Following is the task:
我的朋友创建了一个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
I already executed this rake task in my localhost, but I deploy my project to heroku and now my project won't open online. I don't remember what's the command to execute rake tasks and I can't find it in no place.
我已经在我的localhost中执行了这个rake任务,但是我将我的项目部署到heroku,现在我的项目无法在线打开。我不记得执行rake任务的命令是什么,我无法在任何地方找到它。
My questions is:
我的问题是:
- What's the command to execute rake tasks?
- What's the command to execute rake tasks on heroku? Just "heroku run "?
执行rake任务的命令是什么?
在heroku上执行rake任务的命令是什么?只是“heroku跑”?
Thanks!
1 个解决方案
#1
3
heroku run bundle exec rake db:update_database
should do.
bundle exec
ensures that the script is run in the context of current bundle.
bundle exec确保脚本在当前bundle的上下文中运行。
#1
3
heroku run bundle exec rake db:update_database
should do.
bundle exec
ensures that the script is run in the context of current bundle.
bundle exec确保脚本在当前bundle的上下文中运行。