Append string to a route with a slash operator
If you need to append string to some route to build a path name you can use few ways:
Rails.root + 'foo/bar'
[Rails.root, 'foo/bar'].join('/')
"#{Rails.root}/foo/bar"
But also there is a Pathname#/
method, so you can append string to route using a slash:
Rails.root/'foo/bar' # => #<Pathname:/Users/alex/myproject/foo/bar>
Looks more readable!
Discover More Reads
Categories: