Skip to content

Commit cbb7257

Browse files
committed
[Doc] Update the "Rails configuration tip" section
Follow up rails/rails#50506.
1 parent ebf1762 commit cbb7257

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ end
6565

6666
## Rails configuration tip
6767

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

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

87+
In Rails 7.2+, it is recommended to use `config.generators.apply_rubocop_autocorrect_after_generate!` instead of the above setting:
88+
89+
```diff
90+
# config/environments/development.rb
91+
Rails.application.configure do
92+
(snip)
93+
# Apply autocorrection by RuboCop to files generated by `bin/rails generate`.
94+
- # config.generators.apply_rubocop_autocorrect_after_generate!
95+
+ config.generators.apply_rubocop_autocorrect_after_generate!
96+
end
97+
```
98+
99+
You only need to uncomment.
100+
87101
## The Cops
88102

89103
All cops are located under

0 commit comments

Comments
 (0)