Uniform paths joining in the code generated by rails new
#40215
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds uniformity when joining paths (
Rails.root.join(...)
) in the code generated byrails new
command.rails new
currently generates the code with slashes in this places:https://github.com/rails/rails/blob/6-0-stable/railties/lib/rails/generators/test_unit/generator/templates/generator_test.rb.tt#L7
https://github.com/rails/rails/blob/6-0-stable/railties/lib/rails/generators/rails/app/templates/config/storage.yml.tt#L3
https://github.com/rails/rails/blob/6-0-stable/railties/lib/rails/generators/rails/app/templates/config/storage.yml.tt#L7
https://github.com/rails/rails/blob/6-0-stable/railties/lib/rails/generators/rails/app/templates/config/storage.yml.tt#L21
And using arguments here:
https://github.com/rails/rails/blob/6-0-stable/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt#L17 (this PR changes it to slashes also).
Other Information
Based on my personal experience, having Rubocop running while teaching school kids Ruby/Rails is a huge time saver. No need to point them to same mistakes all the time. We also create new Rails apps a lot and each time
config/environments/development.rb:17:6: C: Rails/FilePath: Please use Rails.root.join('path/to') instead.
offence is reported. We have rule disabled for a long time and I finally gather up the courage to submit this PR 馃挭馃槃.I understand that this change could be considered cosmetic in nature and not accepted but the change from slashes to arguments https://github.com/rails/rails/pull/31530/files was in fact also cosmetic cause we already knew it does not change anything https://twitter.com/tenderlove/status/842064491936280576 馃槃