mirror of https://github.com/rails/rails
Add example of simple environment config extending
Follow up to https://github.com/rails/rails/issues/47570 [ci skip] Update guides/source/configuring.md Co-authored-by: Hartley McGuire <skipkayhil@gmail.com> Update guides/source/configuring.md Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
This commit is contained in:
parent
13dc6e76fb
commit
e0e7030f99
|
@ -3018,7 +3018,16 @@ development:
|
|||
|
||||
By default Rails ships with three environments: "development", "test", and "production". While these are sufficient for most use cases, there are circumstances when you want more environments.
|
||||
|
||||
Imagine you have a server which mirrors the production environment but is only used for testing. Such a server is commonly called a "staging server". To define an environment called "staging" for this server, just create a file called `config/environments/staging.rb`. Please use the contents of any existing file in `config/environments` as a starting point and make the necessary changes from there.
|
||||
Imagine you have a server which mirrors the production environment but is only used for testing. Such a server is commonly called a "staging server". To define an environment called "staging" for this server, just create a file called `config/environments/staging.rb`. Since this is a production-like environment, you could copy the contents of `config/environments/production.rb` as a starting point and make the necessary changes from there. It's also possible to require and extend other environment configurations like this:
|
||||
|
||||
```ruby
|
||||
# config/environments/staging.rb
|
||||
require_relative "production"
|
||||
|
||||
Rails.application.configure do
|
||||
# Staging overrides
|
||||
end
|
||||
```
|
||||
|
||||
That environment is no different than the default ones, start a server with `bin/rails server -e staging`, a console with `bin/rails console -e staging`, `Rails.env.staging?` works, etc.
|
||||
|
||||
|
|
Loading…
Reference in New Issue