Skip to content

Commit c2dd421

Browse files
authored
Merge pull request #1220 from andyw8/patch-1
`after_generator` config should only be for development
2 parents b1a8c86 + 5b3ec4f commit c2dd421

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,15 @@ end
6666
## Rails configuration tip
6767

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

7171
```ruby
72-
# config/application.rb
73-
module YourCoolApp
74-
class Application < Rails::Application
75-
config.generators.after_generate do |files|
76-
parsable_files = files.filter { |file| file.end_with?('.rb') }
77-
unless parsable_files.empty?
78-
system("bundle exec rubocop -A --fail-level=E #{parsable_files.shelljoin}", exception: true)
79-
end
72+
# config/environments/development.rb
73+
Rails.application.configure do
74+
config.generators.after_generate do |files|
75+
parsable_files = files.filter { |file| file.end_with?('.rb') }
76+
unless parsable_files.empty?
77+
system("bundle exec rubocop -A --fail-level=E #{parsable_files.shelljoin}", exception: true)
8078
end
8179
end
8280
end

0 commit comments

Comments
 (0)