Arkadiusz Oleksy said almost 7 years ago on Routing Partials :

Hi.

You can simplify your draw method to not branch out on subpath. Pathname#join accepts multiple arguments and if one of them is empty string, then it will not be included in created path:

def draw(routes_name, sub_path=nil)
  Rails.root.join('config/routes', sub_path.to_s, "#{routes_name}.rb")
end
draw :v1, 'api'
# => #<Pathname:/path/to/app/config/routes/api/v1.rb>
draw :v1
# => #<Pathname:/path/to/app/config/routes/v1.rb>