简体   繁体   English

从RAILS_ROOT外部运行rake任务

[英]Run rake task from outside RAILS_ROOT

My RAILS_ROOT is /usr/local/www/application/ 我的RAILS_ROOT是/ usr / local / www / application /

If I run 'rake db:migrate RAILS_ENV=production" from within the RAILS_ROOT it works fine. 如果我从RAILS_ROOT中运行'rake db:migrate RAILS_ENV = production',它可以正常工作。

However I can't seem to find a way to run the same command from outside the RAILS_ROOT. 但是我似乎找不到从RAILS_ROOT外部运行相同命令的方法。

Try: 尝试:

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

I think you need to re-think your question. 我想你需要重新思考你的问题。 When running rake without specifying a rakefile, it's going to search in the current directory for said rakefile. 在没有指定rakefile的情况下运行rake ,它将在当前目录中搜索所述rakefile。 In a directory besides RAILS_ROOT, it's going to find no rakefile or the wrong Rakefile 在除RAILS_ROOT之外的目录中,它将找不到rakefile或错误的Rakefile

rake -rakefile /usr/local/www/application/Rakefile db:migrate RAILS_ENV=production might work (assuming the rake user guide is correct), though you may have to be in the directory for poorly designed plugins/library modifications. rake -rakefile /usr/local/www/application/Rakefile db:migrate RAILS_ENV=production可能有效(假设rake用户指南是正确的),尽管你可能必须在目录中进行设计不良的插件/库修改。

尝试

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM