File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 65
65
66
66
# # Rails configuration tip
67
67
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
69
69
your `config/environments/development.rb` to apply RuboCop autocorrection to code generated by `bin/rails g`.
70
70
71
71
` ` ` ruby
@@ -84,6 +84,20 @@ It uses `rubocop -A` to apply `Style/FrozenStringLiteralComment` and other unsaf
84
84
` rubocop -A` is unsafe autocorrection, but code generated by default is simple and less likely to
85
85
be incompatible with `rubocop -A`. If you have problems you can replace it with `rubocop -a` instead.
86
86
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
+
87
101
## The Cops
88
102
89
103
All cops are located under
You can’t perform that action at this time.
0 commit comments