Skip to content

Commit

Permalink
after_generator config should only be for development
Browse files Browse the repository at this point in the history
I think it makes more sense to have this code only present in development.
  • Loading branch information
andyw8 authored Dec 17, 2023
1 parent 1fe6385 commit 5b3ec4f
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 5b3ec4f

Please sign in to comment.