While grouping routes using scope, I came across the following:
# config/routes.rb
module Dashy
class Routes < Hanami::Routes
get "foo", to: "action.foo", as: :foo
scope "myscope" do
get "foo", to: "action.foo", as: :foo
end
scope "my-scope" do
get "foo", to: "action.foo", as: :foo
end
slice :myslice, at: "/myslice" do
get "foo", to: "action.foo", as: :foo
end
slice :my_slice, at: "/my-slice" do
get "foo", to: "action.foo", as: :foo
end
end
end
The following routes and helpers are created:
GET /foo action.foo as :foo
GET /myscope/foo action.foo as :myscope_foo
GET /my-scope/foo action.foo as :"my-scope_foo"
GET /myslice/foo action.foo as :myslice_foo
GET /my-slice/foo action.foo as :"my-slice_foo"
By convention, dashes are preferred over underscores in URLs, but this results in ugly helpers here.
How about to convert dashes in URL fragments to underscores in helper names?
I’ve implemented this into hanami-router, here’s the PR:
Since this is only my second PR to Hanami, I have a few technical questions:
How to deal with # @since comments without knowing the version this addition might roll with? (I guessed the next minor, so # @since 2.3.0 in this case.)
Should the CHANGELOG be updated and if so under what title e.g. ## v2.3.0 or ## Main?