Useful Ruby Pathname method

Posted Almost 4 years ago. Visible to the public.

If you have a Ruby Pathname Show archive.org snapshot , you can use the method :/ Show archive.org snapshot to append filepaths to it.

With this method, Ruby code can look like this:

Rails.root/"features"/"fixtures"/"picture.jpg"

Alternatively you can use the #join method, which feels less magic:

Rails.root.join('features', 'fixtures', 'picture.jpg')
Niklas Hä.
Last edit
Almost 4 years ago
Emanuel
License
Source code in this card is licensed under the MIT License.
Posted by Niklas Hä. to makandra dev (2020-08-13 11:44)