Run rake task from outside RAILS_ROOT

2019-05-06 23:53发布

My RAILS_ROOT is /usr/local/www/application/

If I run 'rake db:migrate RAILS_ENV=production" from within the RAILS_ROOT it works fine.

However I can't seem to find a way to run the same command from outside the RAILS_ROOT.

3条回答
一夜七次
2楼-- · 2019-05-07 00:25

Try

cd /user/local/www/application && rake db:migrate RAILS_ENV=production
查看更多
爷的心禁止访问
3楼-- · 2019-05-07 00:36

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. In a directory besides RAILS_ROOT, it's going to find no rakefile or the wrong 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.

查看更多
Deceive 欺骗
4楼-- · 2019-05-07 00:43

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
查看更多
登录 后发表回答