Skip to content

Commit

Permalink
Merge pull request #1220 from andyw8/patch-1
Browse files Browse the repository at this point in the history
`after_generator` config should only be for development
  • Loading branch information
koic committed Dec 22, 2023
2 parents b1a8c86 + 5b3ec4f commit c2dd421
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,15 @@ end
## Rails configuration tip

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

```ruby
# config/application.rb
module YourCoolApp
class Application < Rails::Application
config.generators.after_generate do |files|
parsable_files = files.filter { |file| file.end_with?('.rb') }
unless parsable_files.empty?
system("bundle exec rubocop -A --fail-level=E #{parsable_files.shelljoin}", exception: true)
end
# config/environments/development.rb
Rails.application.configure do
config.generators.after_generate do |files|
parsable_files = files.filter { |file| file.end_with?('.rb') }
unless parsable_files.empty?
system("bundle exec rubocop -A --fail-level=E #{parsable_files.shelljoin}", exception: true)
end
end
end
Expand Down

0 comments on commit c2dd421

Please sign in to comment.