From 5b3ec4f1714526549425193ca4f27c988dd0b4cf Mon Sep 17 00:00:00 2001 From: Andy Waite <13400+andyw8@users.noreply.github.com> Date: Sun, 17 Dec 2023 14:35:50 -0500 Subject: [PATCH] `after_generator` config should only be for development I think it makes more sense to have this code only present in development. --- README.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ca42e975a5..4a5892731c 100644 --- a/README.md +++ b/README.md @@ -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