How to create a custom environment in rails by default?

i a createdcustom staging environment in my rails application by adding a new file config/environments/staging.rbthe same as config/environments/development.rband then adding the database configurationconfig/database.yml

staging:
  adapter: sqlite3
  database: db/staging.sqlite3
  pool: 5
  timeout: 5000

Now, I want to make staging default environmentmy application rails instead of developing. How to reach it?

+4
source share
3 answers

Ideally, you need to set the environment variable to .bashrc, for example

  export RAILS_ENV=staging

because it railscompletely depends on the environment variable. But as you said

RAILS_ENV ~/.bashrc ~/.bash_profile . , ~/.bashrc ~/.bash_profile?

, . config/boot.rb

ENV["RACK_ENV"] = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || "staging"

.

  • Rails 4
  • Console
  • dbconsole
  • , โ€‹โ€‹ bashrc zshrc ..
+1

application.rb Bundler.require

ENV['RAILS_ENV'] ||= 'staging'
+1

  ENV ['RAILS_ENV'] || = 'custom_development' boot.rb . .

  • rake
  • dbconsole

.

0

Source: https://habr.com/ru/post/1526135/


All Articles