From 3f658bceca5050fc5600bd1b9c680c2d318b4bd6 Mon Sep 17 00:00:00 2001 From: Sven Schwyn Date: Mon, 5 Jan 2026 21:02:46 +0100 Subject: [PATCH 1/2] Fix typos --- content/v2.3/routing/overview.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/v2.3/routing/overview.md b/content/v2.3/routing/overview.md index ea20da7d..64975f79 100644 --- a/content/v2.3/routing/overview.md +++ b/content/v2.3/routing/overview.md @@ -28,8 +28,8 @@ Each route in Hanami's router is comprised of: Endpoints are usually actions within your application, but they can also be a block, a [Rack](https://github.com/rack/rack) application, or anything that responds to `#call`. ```ruby -get "/books", to: "books.index" # Invokes the Bookshelf::Actions:Books::Index action -post "/books", to: "books.create" # Invokes the Bookshelf::Actions:Books::Create action +get "/books", to: "books.index" # Invokes the Bookshelf::Actions::Books::Index action +post "/books", to: "books.create" # Invokes the Bookshelf::Actions::Books::Create action get "/rack-app", to: RackApp.new get "/my-lambda", to: ->(env) { [200, {}, ["A Rack compatible response"]] } ``` From 11e5dbbbd8ed607834a9b9a96888a455e44fc995 Mon Sep 17 00:00:00 2001 From: Sven Schwyn Date: Mon, 5 Jan 2026 21:03:09 +0100 Subject: [PATCH 2/2] Add section on grouping actions in modules/subdirectories --- content/v2.3/routing/overview.md | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/content/v2.3/routing/overview.md b/content/v2.3/routing/overview.md index 64975f79..a04c8446 100644 --- a/content/v2.3/routing/overview.md +++ b/content/v2.3/routing/overview.md @@ -322,6 +322,44 @@ scope "authors/:author_id", as: :author do end ``` +## Grouping + +To avoid conflicting source file names, you may at times wish to group actions by adding additional segments to the `to` endpoint: + +```ruby +module Bookshelf + class Routes < Hanami::Routes + scope "sign-up" do + get "email", to: "sign_up.email.new" # Invokes the Bookshelf::Actions:SignUp::Email::New action + get "phone", to: "sign_up.phone.new" # Invokes the Bookshelf::Actions:SignUp::Phone::New action + end + scope "sign-in" do + get "email", to: "sign_in.email.new" # Invokes the Bookshelf::Actions:SignIn::Email::New action + get "phone", to: "sign_in.phone.new" # Invokes the Bookshelf::Actions:SignIn::Phone::New action + end + end +end +``` + +This wraps the actions with additional `Email` and `Phone` modules and therefore organizes their source files accordingly: + +``` +app +└── actions + ├── sign_in + | ├── email + | | └── new.rb + | └── phone + | └── new.rb + └── sign_up + ├── email + | └── new.rb + └── phone + └── new.rb +``` + +The same organization applies to the related default views and templates as well. + ## Redirects Redirects can be added using `redirect`.