diff options
-rw-r--r-- | railties/lib/rails_generator/generators/applications/app/template_runner.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/railties/lib/rails_generator/generators/applications/app/template_runner.rb b/railties/lib/rails_generator/generators/applications/app/template_runner.rb index c6113648e6..1e0c6cc3ff 100644 --- a/railties/lib/rails_generator/generators/applications/app/template_runner.rb +++ b/railties/lib/rails_generator/generators/applications/app/template_runner.rb @@ -359,6 +359,12 @@ module Rails !yes?(question) end + # Run a regular expression replacement on a file + # + # ==== Example + # + # gsub_file 'app/controllers/application_controller.rb', /#\s*(filter_parameter_logging :password)/, '\1' + # def gsub_file(relative_destination, regexp, *args, &block) path = destination_path(relative_destination) content = File.read(path).gsub(regexp, *args, &block) @@ -369,4 +375,4 @@ module Rails File.join(root, relative_destination) end end -end
\ No newline at end of file +end |