从RAILS_ROOT外运行rake任务

4

我的RAILS_ROOT是/usr/local/www/application/。

如果我从RAILS_ROOT中运行'rake db:migrate RAILS_ENV=production',它可以正常工作。

然而,我似乎找不到在RAILS_ROOT之外运行相同命令的方法。

3个回答

12

尝试:

rake -f $RAILS_ROOT/Rakefile db:migrate RAILS_ENV=production
# Assuming you set the environment variable. 
# Else, just replace $RAILS_ROOT by actual value

3
我认为你需要重新思考你的问题。当运行rake而没有指定rakefile时,它会在当前目录中搜索该rakefile。在RAILS_ROOT以外的目录中,它将找不到rakefile或错误的Rakefile。 rake -rakefile /usr/local/www/application/Rakefile db:migrate RAILS_ENV=production可能会起作用(假设rake用户指南是正确的),但你可能需要在设计不良的插件/库修改目录中进行操作。

1

尝试一下

cd /user/local/www/application && rake db:migrate RAILS_ENV=production

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接