你如何与领班一起设置Rails环境?
例如,如果我想跑步 bundle exec rake assets:precompile 在我的开发机器上,但是我想将Rails环境设置为生产环境,这样我就可以确切地看到这个过程在生产服务器上的运行方式—我可以通过这样做来使用普通的Rails RAILS_ENV=production bundle exec rake assets:precompile .
bundle exec rake assets:precompile
RAILS_ENV=production bundle exec rake assets:precompile
但是我该怎么和工头一起做呢?例如,我知道我能做到 bundle exec foreman run rake assets:precompile 但这并没有将Rails环境指定为生产环境。
bundle exec foreman run rake assets:precompile
解决办法是 to use a .env file in your project's root directory . 在该文件中,添加以下行:
.env
RAILS_ENV=production
现在,只要您在本地运行Foreman,它就会将Rails环境设置为生产环境。所以,如果你跑步 bundle exec foreman run rake assets:precompile ,将为该任务生成环境。完成后别忘了把它改回去!;-)