Skip to content

Commit

Permalink
[Doc] Update the "Rails configuration tip" section
Browse files Browse the repository at this point in the history
  • Loading branch information
koic committed Sep 9, 2024
1 parent ebf1762 commit cbb7257
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ end

## Rails configuration tip

If you are using Rails 6.1 or newer, add the following `config.generators.after_generate` setting to
In Rails 6.1+, add the following `config.generators.after_generate` setting to
your `config/environments/development.rb` to apply RuboCop autocorrection to code generated by `bin/rails g`.

```ruby
Expand All @@ -84,6 +84,20 @@ It uses `rubocop -A` to apply `Style/FrozenStringLiteralComment` and other unsaf
`rubocop -A` is unsafe autocorrection, but code generated by default is simple and less likely to
be incompatible with `rubocop -A`. If you have problems you can replace it with `rubocop -a` instead.

In Rails 7.2+, it is recommended to use `config.generators.apply_rubocop_autocorrect_after_generate!` instead of the above setting:

```diff
# config/environments/development.rb
Rails.application.configure do
(snip)
# Apply autocorrection by RuboCop to files generated by `bin/rails generate`.
- # config.generators.apply_rubocop_autocorrect_after_generate!
+ config.generators.apply_rubocop_autocorrect_after_generate!
end
```

You only need to uncomment.

## The Cops

All cops are located under
Expand Down

0 comments on commit cbb7257

Please sign in to comment.