I'm setting up a new Rails project and after giving it an initial tidy with Rubocop, I'm left with a single offense.
Rubop complains:
config/environments/development.rb:16:6: C: Please use Rails.root.join('path', 'to') instead.
if Rails.root.join("tmp/caching-dev.txt").exist?
I see that Rails.root
returns the path of the current project. So I've tried
if File.join(Rails.root, "tmp/caching-dev.text").exist?
instead. But still, Rubocop complains:
config/environments/development.rb:17:6: C: Please use Rails.root.join('path', 'to') instead.
if File.join(Rails.root, "tmp/caching-dev.text").exist?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
What are the path
and root
arguments meant to be? Surely Rails.root
is the path?!
IMHO, Pathname and /
are not used enough.
if (Rails.root / 'tmp' / 'caching-dev.txt').exist?
I think Rubocop is suggesting you to do something like this
if File.exist?(Rails.root.join('tmp', 'caching-dev.txt'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With