Three kinds of production environment rails

Recommended for you: Get network issues from WhatsUp Gold. Not end users.
Rails defines three environment, respectively is "production", "environment" and "test environment". The Rails console is used by default is "development environment":
$ rails c
Loading development environment
>> Rails.env
=> "development"
>> Rails.env.development?
=> true
>> Rails.env.test?
=> false

As previously shown, the Rails object has a env attribute, attribute can also call the Boolean value corresponding to the method, for example, Rails.env.test?, in the "test environment" in the return value is true, while the return value in the other two environment is false.

If you need to use the console in other environments (e.g., debug in the "test environment"), just put the environment name passed to console commands:
$ rails c test
Loading test environment
>> Rails.env
=> "test"
>> Rails.env.test?
=> true

Rails local server and console, use the default "development environment", can also be run in other environments:
$ rails server --environment production

If you want to in the "production" of running the application, to provide production environment database. Execute the rake db:migrate command in the "production" can create "environment" for the database:
$ bundle exec rake db:migrate RAILS_ENV=production
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Heather at February 23, 2014 - 11:32 AM