A Rails developer shares first impressions after working through the official Hanami 3.0 tutorial. Hanami emphasizes separation of concerns, with dedicated action classes instead of monolithic controllers, first-class view/template classes, an 'operations' layer for business logic, and 'slices' for breaking monoliths apart (compared favorably to Django's app structure). The author used Ruby 4.0 via mise, appreciated Hanami's CLI generators and RSpec as the default testing library, found the data-mapping layer the steepest learning curve, and plans to port a sample Rails app to Hanami in future posts. The piece closes with a plug for the author's own Rails testing book.

4m read timeFrom leftofthe.dev
Post cover image
Table of contents
First impressionsRouting, actions, and viewsData layerOther things I noticedNext steps

Questions this post answers

How does Hanami handle controllers differently from Rails?

Hanami splits each controller action into its own dedicated action class, rather than grouping multiple actions under one controller class as Rails does. This lets each action handle its own params independently instead of relying on a single Strong Parameters-style approach shared across all actions in a Rails controller. Developers weighing Rails against Hanami's action-based design can follow framework comparisons like this on daily.dev.

What testing library does Hanami use by default?

Hanami uses RSpec as its default testing library, rather than Minitest. This aligns with common Rails developer preferences, since many Rails teams already favor RSpec over Minitest for behavior-driven testing style. Ruby developers picking a testing stack can track framework defaults like this on daily.dev.

What are slices in the Hanami framework?

Slices are Hanami's official mechanism for breaking a monolithic application into separate app-like components, similar in spirit to Django's app structure. They offer a built-in alternative to Rails engines, which some developers find cumbersome for achieving the same kind of modular separation. Anyone comparing modular architecture options across Ruby and Python frameworks can follow deep dives like this on daily.dev.

1.5K Impressions