Ruby on Rails,rake db:seed或db:reset - 你如何决定哪种模式(开发/测试/生产)?

时间:2023-01-16 09:53:28

With Ruby on Rails, when you reset or re-seed the database using rake db:seed or db:reset - how do you dictate which mode (development/test/production) the operation is to be in?

使用Ruby on Rails,当您使用rake db:seed或db:reset重置或重新种子数据库时 - 如何指定操作所处的模式(开发/测试/生产)?

I'm using Sqlite for development, and postgresql for both test and production - but with different connection arguments. I do not seem to be able to control which mode Rails runs on on my development box (I'm running in a virtual machine, Ubuntu 13.l0) nor when on Heroku.

我正在使用Sqlite进行开发,并使用postgresql进行测试和生产 - 但使用不同的连接参数。我似乎无法控制Rails在我的开发盒上运行的模式(我在虚拟机中运行,Ubuntu 13.l0),也不能在Heroku上运行。

Also, how do you dictate which mode (development/test/production) to run your app in, when running it on Heroku? The way that Heroku's document suggests, does not work (that is, putting into the Procfile a single line with web: bundle exec unicorn -p $PORT -E $RACK_ENV and including a .env file that has RACK_ENV=test (for example). ? Thank you for any help. I am really hating Ruby-on-Rails.

另外,在Heroku上运行应用程序时,如何指定运行应用程序的模式(开发/测试/生产)? Heroku的文档建议的方式不起作用(也就是说,使用web将procfile放入一行:bundle exec unicorn -p $ PORT -E $ RACK_ENV并包含一个具有RACK_ENV = test的.env文件(例如)感谢您的帮助。我真的很讨厌Ruby-on-Rails。

1 个解决方案

#1


12  

You can set environment with RAILS_ENV env variable, for example:

您可以使用RAILS_ENV env变量设置环境,例如:

RAILS_ENV=production bundle exec rake db:seed

#1


12  

You can set environment with RAILS_ENV env variable, for example:

您可以使用RAILS_ENV env变量设置环境,例如:

RAILS_ENV=production bundle exec rake db:seed