# questions

**URL:** https://discourse.hanakai.org/c/questions/9.md?page=1

[Latest](https://discourse.hanakai.org/latest.md) · [Categories](https://discourse.hanakai.org/categories.md)

**Page:** 2

---

## [Slices in a namespace](https://discourse.hanakai.org/t/slices-in-a-namespace/1274)

<div class="topic-metadata">

**Author:** [@katafrakt](https://discourse.hanakai.org/u/katafrakt)\
**Replies:** 4\
**Last updated:** [July 10, 2025, 10:24pm UTC](https://discourse.hanakai.org/t/slices-in-a-namespace/1274 "2025-07-10T22:24:44Z")

</div>

Just for fun and science I tried generating a slice in a namespace like this: hanami generate slice utils/healthcheck This is what I found: It created a file structure as I expected Updated config/routes.rb Created …

---

## [Access expose in layout](https://discourse.hanakai.org/t/access-expose-in-layout/1270)

<div class="topic-metadata">

**Author:** [@carolync](https://discourse.hanakai.org/u/carolync)\
**Replies:** 5\
**Last updated:** [July 9, 2025, 11:50am UTC](https://discourse.hanakai.org/t/access-expose-in-layout/1270 "2025-07-09T11:50:42Z")

</div>

Hello, I exposed information about if a user is logged in in the base action.rb. I can access those exposes in the template, but not the layout. Is there. a trick I am missing to access the exposed variables in the lay…

---

## [Skip a callback from inherited action](https://discourse.hanakai.org/t/skip-a-callback-from-inherited-action/1255)

<div class="topic-metadata">

**Author:** [@krzykamil](https://discourse.hanakai.org/u/krzykamil)\
**Replies:** 5\
**Last updated:** [June 30, 2025, 8:16pm UTC](https://discourse.hanakai.org/t/skip-a-callback-from-inherited-action/1255 "2025-06-30T20:16:54Z")

</div>

Hey hey I cannot find this info in docs or in source code Let’s say we have a base action: class Action \< Hanami::Action include Dry::Monads\[:result\] before do |request, response| authenticate\_user(requ…

---

## [Introspect template and partial](https://discourse.hanakai.org/t/introspect-template-and-partial/1254)

<div class="topic-metadata">

**Author:** [@svoop](https://discourse.hanakai.org/u/svoop)\
**Replies:** 3\
**Last updated:** [June 28, 2025, 6:25pm UTC](https://discourse.hanakai.org/t/introspect-template-and-partial/1254 "2025-06-28T18:25:19Z")

</div>

On a site translated with the i18n gem, I try to shorten the length of keys of translations in templates. The following helper does a similar trick as Rails. The shortcut \<%= t(".title") %\> in templates/users/show.html.e…

---

## [Mounting Rack Middleware at the action level](https://discourse.hanakai.org/t/mounting-rack-middleware-at-the-action-level/1235)

<div class="topic-metadata">

**Author:** [@buszu](https://discourse.hanakai.org/u/buszu)\
**Replies:** 7\
**Last updated:** [June 29, 2025, 9:05am UTC](https://discourse.hanakai.org/t/mounting-rack-middleware-at-the-action-level/1235 "2025-06-29T09:05:07Z")

</div>

Hello, I think that mounting rack middleware at the action level was possible in Hanami 1.3. I wanted to leverage this way of doing so to make some nice integration with rodauth. I found this page for the v2.0: V2.0: Ra…

---

## [Event Registration Expectations (Dry Monitor)](https://discourse.hanakai.org/t/event-registration-expectations-dry-monitor/1263)

<div class="topic-metadata">

**Author:** [@aaronmallen](https://discourse.hanakai.org/u/aaronmallen)\
**Replies:** 5\
**Last updated:** [June 26, 2025, 10:08pm UTC](https://discourse.hanakai.org/t/event-registration-expectations-dry-monitor/1263 "2025-06-26T22:08:22Z")

</div>

What are the expectations around registering, subscribing, and publishing events with the built in “notfications” component, which is an instance of Dry::Monitior::Notifications? The following is a transcript of a disco…

---

## [Allowing a url with multiple formats](https://discourse.hanakai.org/t/allowing-a-url-with-multiple-formats/1252)

<div class="topic-metadata">

**Author:** [@carolync](https://discourse.hanakai.org/u/carolync)\
**Replies:** 5\
**Last updated:** [June 26, 2025, 8:59pm UTC](https://discourse.hanakai.org/t/allowing-a-url-with-multiple-formats/1252 "2025-06-26T20:59:12Z")

</div>

Hi! I’m new to Hanami. I’m trying to convert a Rails application over to a Hanami application. In the rails app we have a health page that can be viewed in either html or json. I have implemented that as two actions,…

---

## [Best Practices for data transforms](https://discourse.hanakai.org/t/best-practices-for-data-transforms/1237)

<div class="topic-metadata">

**Author:** [@aaronmallen](https://discourse.hanakai.org/u/aaronmallen)\
**Replies:** 2\
**Last updated:** [June 26, 2025, 3:21pm UTC](https://discourse.hanakai.org/t/best-practices-for-data-transforms/1237 "2025-06-26T15:21:52Z")

</div>

Dear Hanami, This is a question about best practices for transforms. TL;DR Where are we putting our transformation/normalization logic for create/update methods in our Repos? I have a contract called NewApplicationCon…

---

## [Does hanami-assets process .scss files out of the box ?](https://discourse.hanakai.org/t/does-hanami-assets-process-scss-files-out-of-the-box/1001)

<div class="topic-metadata">

**Author:** [@FranckP](https://discourse.hanakai.org/u/FranckP)\
**Replies:** 3\
**Last updated:** [June 18, 2025, 12:43pm UTC](https://discourse.hanakai.org/t/does-hanami-assets-process-scss-files-out-of-the-box/1001 "2025-06-18T12:43:18Z")

</div>

Hi there, I am testing hanami 2.1 for a fews weeks now. I like its architecture together with ROM-db. As it is a young framework, it is difficult to find answers when a problem occur. Here is mine : For two days now I …

---

## [Phlex integration Issues](https://discourse.hanakai.org/t/phlex-integration-issues/1230)

<div class="topic-metadata">

**Author:** [@aaronmallen](https://discourse.hanakai.org/u/aaronmallen)\
**Replies:** 2\
**Last updated:** [June 16, 2025, 3:30pm UTC](https://discourse.hanakai.org/t/phlex-integration-issues/1230 "2025-06-16T15:30:42Z")

</div>

Dear Hanami, I’m following the patterns established here by Paweł GitHub - katafrakt/palaver: a toy forum software in Hanami 2 to establish Phlex in my project. The two important pieces are this extension: # frozen\_st…

---

## [I18n for "static" site](https://discourse.hanakai.org/t/i18n-for-static-site/1227)

<div class="topic-metadata">

**Author:** [@svoop](https://discourse.hanakai.org/u/svoop)\
**Replies:** 0\
**Last updated:** [June 9, 2025, 12:00pm UTC](https://discourse.hanakai.org/t/i18n-for-static-site/1227 "2025-06-09T12:00:36Z")

</div>

Hanami is great for static sites using the Parklife gem to build the static version. However, things get a little trickier when a site has to be translated. Localizing the routes is the easy part: module MySite class…

---

## [How do you set up a file upload route correctly for a JSON-REST API?](https://discourse.hanakai.org/t/how-do-you-set-up-a-file-upload-route-correctly-for-a-json-rest-api/1222)

<div class="topic-metadata">

**Author:** [@wuarmin](https://discourse.hanakai.org/u/wuarmin)\
**Replies:** 3\
**Last updated:** [June 3, 2025, 7:42am UTC](https://discourse.hanakai.org/t/how-do-you-set-up-a-file-upload-route-correctly-for-a-json-rest-api/1222 "2025-06-03T07:42:55Z")

</div>

Hey :waving\_hand: I have a slice with a JSON Rest API. So the main actions format is :json. In this api i also need an endpoint to upload files. Because of this I cannot set config.actions.format :json at the slice conf…

---

## [Validation contracts (using rules) in actions](https://discourse.hanakai.org/t/validation-contracts-using-rules-in-actions/1197)

<div class="topic-metadata">

**Author:** [@devaniljr](https://discourse.hanakai.org/u/devaniljr)\
**Replies:** 1\
**Last updated:** [April 14, 2025, 11:14pm UTC](https://discourse.hanakai.org/t/validation-contracts-using-rules-in-actions/1197 "2025-04-14T23:14:30Z")

</div>

I’m confused about parameter validation on Hanami 2.2. I tried to do a password\_confirmation validation, but I couldn’t use dry-validation custom rules. I found a reference to a “.confirmation” field on github (Code sear…

---

## [Improving the TechEmpower results](https://discourse.hanakai.org/t/improving-the-techempower-results/1190)

<div class="topic-metadata">

**Author:** [@p81](https://discourse.hanakai.org/u/p81)\
**Replies:** 3\
**Last updated:** [April 14, 2025, 5:45am UTC](https://discourse.hanakai.org/t/improving-the-techempower-results/1190 "2025-04-14T05:45:59Z")

</div>

Hi there, I’ve added Hanami to the TechEmpower benchmarks: I’d like to improve the results. Currently I’m doing the following to update the the World model: The problem here is that this loads the world model twice…

---

## [Disable RackLogger in favor of manually hooking into actions' "handle" for logging requests](https://discourse.hanakai.org/t/disable-racklogger-in-favor-of-manually-hooking-into-actions-handle-for-logging-requests/1132)

<div class="topic-metadata">

**Author:** [@Drowze](https://discourse.hanakai.org/u/Drowze)\
**Replies:** 1\
**Last updated:** [March 19, 2025, 6:35am UTC](https://discourse.hanakai.org/t/disable-racklogger-in-favor-of-manually-hooking-into-actions-handle-for-logging-requests/1132 "2025-03-19T06:35:59Z")

</div>

Hello :wave: I’ve been spending a few hours investigating but couldn’t yet find a clean way - is it possible to disable rack\_monitor completely? My intention is to hook around the Hanami::Action#call method, so it’s eas…

---

## [Hanami 2: mailer or mail gem](https://discourse.hanakai.org/t/hanami-2-mailer-or-mail-gem/1100)

<div class="topic-metadata">

**Author:** [@svoop](https://discourse.hanakai.org/u/svoop)\
**Replies:** 3\
**Last updated:** [March 12, 2025, 7:06pm UTC](https://discourse.hanakai.org/t/hanami-2-mailer-or-mail-gem/1100 "2025-03-12T19:06:31Z")

</div>

Doing stuff with emails has always been a peculiar kind of fun and as splitting the email atom demonstrates, even more so when using emails for auth. Being restrictive and always up-to-date on versions therefore are key…

---

## [Trouble testing the result of an operation](https://discourse.hanakai.org/t/trouble-testing-the-result-of-an-operation/1121)

<div class="topic-metadata">

**Author:** [@stephan](https://discourse.hanakai.org/u/stephan)\
**Replies:** 12\
**Last updated:** [March 12, 2025, 12:03pm UTC](https://discourse.hanakai.org/t/trouble-testing-the-result-of-an-operation/1121 "2025-03-12T12:03:13Z")

</div>

After I got my sample working with the help of A hanami slice in a Rails app - #8 by cllns I ran into a testing issue, which makes me wonder whether I even understood the basic of how you’d use / test the result of an op…

---

## [How to Reuse Relations Across Slices in Hanami?](https://discourse.hanakai.org/t/how-to-reuse-relations-across-slices-in-hanami/1173)

<div class="topic-metadata">

**Author:** [@panteo](https://discourse.hanakai.org/u/panteo)\
**Replies:** 2\
**Last updated:** [March 6, 2025, 5:10am UTC](https://discourse.hanakai.org/t/how-to-reuse-relations-across-slices-in-hanami/1173 "2025-03-06T05:10:59Z")

</div>

Hi everyone, I’m new to Hanami and trying to structure my application correctly. I need some guidance on how to properly share relations across slices. Since relations define our low-level data sources, my understandin…

---

## [Rails app with hanami fails on hanami dependency I didn't (want to) add](https://discourse.hanakai.org/t/rails-app-with-hanami-fails-on-hanami-dependency-i-didnt-want-to-add/1126)

<div class="topic-metadata">

**Author:** [@stephan](https://discourse.hanakai.org/u/stephan)\
**Replies:** 10\
**Last updated:** [March 1, 2025, 10:31pm UTC](https://discourse.hanakai.org/t/rails-app-with-hanami-fails-on-hanami-dependency-i-didnt-want-to-add/1126 "2025-03-01T22:31:03Z")

</div>

After we sorted through a bunch of problems regarding running a (partial) hanami in a Rails app, I worked to incorporate the learnings and fixes into the sample application I am working on. For those interested, the pri…

---

## [Rails and hanami-view don't get along](https://discourse.hanakai.org/t/rails-and-hanami-view-dont-get-along/1122)

<div class="topic-metadata">

**Author:** [@stephan](https://discourse.hanakai.org/u/stephan)\
**Replies:** 8\
**Last updated:** [February 17, 2025, 4:50am UTC](https://discourse.hanakai.org/t/rails-and-hanami-view-dont-get-along/1122 "2025-02-17T04:50:32Z")

</div>

After more help from @cllns in Trouble testing the result of an operation - #2 by cllns I am now looking at a gem dependency incompatibility between Rails and hanami-view and Hanami-controller. Here is a minimal repro: r…

---

## [A hanami slice in a Rails app](https://discourse.hanakai.org/t/a-hanami-slice-in-a-rails-app/1118)

<div class="topic-metadata">

**Author:** [@stephan](https://discourse.hanakai.org/u/stephan)\
**Replies:** 8\
**Last updated:** [February 15, 2025, 2:41pm UTC](https://discourse.hanakai.org/t/a-hanami-slice-in-a-rails-app/1118 "2025-02-15T14:41:08Z")

</div>

I am trying to put together an example of using a slice in a Rails app. This code creates a minimal reproduction: rails new hanami\_sample cd hanami\_sample echo ' gem "hanami", "~\> 2.2" gem "dry-operation" ' \>\> Gemfile …

---

## [Route scopes with dashes](https://discourse.hanakai.org/t/route-scopes-with-dashes/1120)

<div class="topic-metadata">

**Author:** [@svoop](https://discourse.hanakai.org/u/svoop)\
**Replies:** 3\
**Last updated:** [February 14, 2025, 7:43pm UTC](https://discourse.hanakai.org/t/route-scopes-with-dashes/1120 "2025-02-14T19:43:04Z")

</div>

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: "a…

---

## [How to compose params?](https://discourse.hanakai.org/t/how-to-compose-params/1064)

<div class="topic-metadata">

**Author:** [@vladimirtcats](https://discourse.hanakai.org/u/vladimirtcats)\
**Replies:** 3\
**Last updated:** [February 6, 2025, 7:31am UTC](https://discourse.hanakai.org/t/how-to-compose-params/1064 "2025-02-06T07:31:26Z")

</div>

Hi everyone I have a params class module MyApp module Actions module Document module Params class Create \< Hanami::Action::Params params do required(:title).filled(:string) …

---

## [Providers and prepare vs boot](https://discourse.hanakai.org/t/providers-and-prepare-vs-boot/1113)

<div class="topic-metadata">

**Author:** [@svoop](https://discourse.hanakai.org/u/svoop)\
**Replies:** 3\
**Last updated:** [February 4, 2025, 11:21am UTC](https://discourse.hanakai.org/t/providers-and-prepare-vs-boot/1113 "2025-02-04T11:21:59Z")

</div>

I have a little prepare/boot misunderstanding it seems: Unlike the default .env approach, I’m loading access tokens using my dry-credentials gem as a provider: # config/providers/credentials.rb Hanami.app.register\_pro…

---

## [Links in slice templates](https://discourse.hanakai.org/t/links-in-slice-templates/1095)

<div class="topic-metadata">

**Author:** [@katafrakt](https://discourse.hanakai.org/u/katafrakt)\
**Replies:** 2\
**Last updated:** [January 16, 2025, 5:36pm UTC](https://discourse.hanakai.org/t/links-in-slice-templates/1095 "2025-01-16T17:36:46Z")

</div>

I wonder what is the recommended way to work with links in slice templates. Let’s say I have an Admin slice that is mounted like this: slice :admin, at: "/admin" It has a very simple routing itself: module Admin cl…

---

## [‘select’ method does not work as expected in hanami-view Part. Probably overrided ?](https://discourse.hanakai.org/t/select-method-does-not-work-as-expected-in-hanami-view-part-probably-overrided/1096)

<div class="topic-metadata">

**Author:** [@FranckP](https://discourse.hanakai.org/u/FranckP)\
**Replies:** 4\
**Last updated:** [January 14, 2025, 10:53am UTC](https://discourse.hanakai.org/t/select-method-does-not-work-as-expected-in-hanami-view-part-probably-overrided/1096 "2025-01-14T10:53:18Z")

</div>

It seems select method is overrided inside Parts. MWE : (context is Hanami 2.2) # app/views/posts/index.rb module MyApp module Views module Posts class Index \< MyApp::View expose :posts do …

---

## [Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive](https://discourse.hanakai.org/t/refused-to-evaluate-a-string-as-javascript-because-unsafe-eval-is-not-an-allowed-source-of-script-in-the-following-content-security-policy-directive/1094)

<div class="topic-metadata">

**Author:** [@devaniljr](https://discourse.hanakai.org/u/devaniljr)\
**Replies:** 2\
**Last updated:** [January 5, 2025, 12:23am UTC](https://discourse.hanakai.org/t/refused-to-evaluate-a-string-as-javascript-because-unsafe-eval-is-not-an-allowed-source-of-script-in-the-following-content-security-policy-directive/1094 "2025-01-05T00:23:27Z")

</div>

Hello. I’m trying to use Alpine.js on Hanami, but I’m getting this error: Refused to evaluate a string as JavaScript because ‘unsafe-eval’ is not an allowed source of script in the following Content Security Policy dir…

---

## [Best place to add or expand cli-commands?](https://discourse.hanakai.org/t/best-place-to-add-or-expand-cli-commands/1053)

<div class="topic-metadata">

**Author:** [@wuarmin](https://discourse.hanakai.org/u/wuarmin)\
**Replies:** 1\
**Last updated:** [January 3, 2025, 9:46am UTC](https://discourse.hanakai.org/t/best-place-to-add-or-expand-cli-commands/1053 "2025-01-03T09:46:18Z")

</div>

Hey :wave:, I have been using Hanami 2 since the early 2.0.alpha versions and overwrote the hanami bin at the beginning. Now I have upgraded to the latest release candidate and would like to switch to something like thi…

---

## [Frontend assets cached during development?](https://discourse.hanakai.org/t/frontend-assets-cached-during-development/1092)

<div class="topic-metadata">

**Author:** [@joeradtke](https://discourse.hanakai.org/u/joeradtke)\
**Replies:** 1\
**Last updated:** [January 2, 2025, 10:54am UTC](https://discourse.hanakai.org/t/frontend-assets-cached-during-development/1092 "2025-01-02T10:54:32Z")

</div>

Is there a way to clear the cache? I am using stimulus controllers which are stored in the assets which I suspect are cached as changes don’t take effect for a few hours.

---

## [Where to create the core (view) components?](https://discourse.hanakai.org/t/where-to-create-the-core-view-components/1085)

<div class="topic-metadata">

**Author:** [@choallin](https://discourse.hanakai.org/u/choallin)\
**Replies:** 3\
**Last updated:** [December 16, 2024, 12:53pm UTC](https://discourse.hanakai.org/t/where-to-create-the-core-view-components/1085 "2024-12-16T12:53:45Z")

</div>

In Phoenix there is a file called core\_components.ex where we can define our core form components (or other very basic components). This is really handy because when we need to redisgn something the core design is DRY’d …

[Previous page](https://discourse.hanakai.org/c/questions/9.md)

[Next page](https://discourse.hanakai.org/c/questions/9.md?page=2)
