i created
a custom staging environment in my rails app by adding new file config/environments/staging.rb
, same as config/environments/development
I have put ENV['RAILS_ENV'] ||= 'custom_development' in boot.rb at the last. It worked.
I have tested
All Worked.
You can try this in your application.rb
after Bundler.require
statement
ENV['RAILS_ENV'] ||= 'staging'
Ideally you have to set environment variable in .bashrc
like
export RAILS_ENV=staging
because rails
is fully dependent on environment variable. But like you said
adding RAILS_ENV in ~/.bashrc or ~/.bash_profile file of the user. will make this application depent on the console, shouldn't it just work independent of ~/.bashrc or ~/.bash_profile file?
Obviously, this is another option. Include this line at the top of config/boot.rb
ENV["RACK_ENV"] = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || "staging"
This will work everywhere. I have tested in following places
bashrc
or zshrc
etc.