Skip to content

Commit e0e7030

Browse files
Add example of simple environment config extending
Follow up to rails#47570 [ci skip] Update guides/source/configuring.md Co-authored-by: Hartley McGuire <[email protected]> Update guides/source/configuring.md Co-authored-by: Jonathan Hefner <[email protected]>
1 parent 13dc6e7 commit e0e7030

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

guides/source/configuring.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3018,7 +3018,16 @@ development:
30183018

30193019
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.
30203020

3021-
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.
3021+
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:
3022+
3023+
```ruby
3024+
# config/environments/staging.rb
3025+
require_relative "production"
3026+
3027+
Rails.application.configure do
3028+
# Staging overrides
3029+
end
3030+
```
30223031
30233032
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.
30243033

0 commit comments

Comments
 (0)