Use Pathname#relative_path_from
:
require 'pathname'
first = Pathname.new '/first/path'
second = Pathname.new '/second/path'
relative = second.relative_path_from first
# ../../second/path
first + relative
# /second/path
Use Pathname#relative_path_from
:
require 'pathname'
first = Pathname.new '/first/path'
second = Pathname.new '/second/path'
relative = second.relative_path_from first
# ../../second/path
first + relative
# /second/path