Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reword Rails best practices #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions docs/rails.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
# Rails conventions
# Rails-specific best practices

## App behavior should be configured via environment variables
## Application configuration

When implementing new features, it should not depend on current
`RAILS_ENV` value, but environment variable(s) specific to the
feature.
Application configuration should **depend on environment variables**,
and absolutely **not rely on `RAILS_ENV`** value (nor `Rails.env`),
respecting the [12-factor app methodology][12-factor config].

* Avoid modifying `config/environments/*.rb`, and keep default
Rails configuration (this will also help when updating Rails)
* Avoid testing:
Specifically, the following rules should be followed:

* Avoid modifying `config/environments/*.rb`: keep default Rails configuration
in there untouched (this will also make Rails upgrades a lot smoother)
* Write application configuration in `config/application.rb`
* Avoid testing any of:
* `ENV["RACK_ENV"]`
* `ENV["RAILS_ENV"]`
* `Rails.env.development?`
* `Rails.env.production?`
* `Rails.env.test?`

Examples:

``` ruby
# bad:
module MyRailsApp
Expand Down Expand Up @@ -75,3 +81,5 @@ Rails.application.routes.draw do
end
end
```

[12-factor config]: https://12factor.net/config