# Should Zeitwerk (autoloader) be configurable?

**URL:** <https://discourse.hanakai.org/t/should-zeitwerk-autoloader-be-configurable/807>\
**Category:** questions\
**Created:** [March 10, 2023, 9:53pm UTC](https://discourse.hanakai.org/t/should-zeitwerk-autoloader-be-configurable/807 "2023-03-10T21:53:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bkuhlmann](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/bkuhlmann/32/475_2.png) [@bkuhlmann](https://discourse.hanakai.org/u/bkuhlmann)\
**Post date:** [March 10, 2023, 9:53pm UTC](https://discourse.hanakai.org/t/should-zeitwerk-autoloader-be-configurable/807/1 "2023-03-10T21:53:19Z")

</div>

Hey. 👋 I’m seeing strange behavior when teaching Zeitwork how to account for non-standard files/constants. Here’s my setup:

```ruby
# demo/config/app.rb
module Demo
  class App < Hanami::App
    autoloader.inflector.inflect "subject_url" => "SubjectURL"
    autoloader.logger = method :puts
  end
end

```

```auto
# lib/demo/subject_url.rb
module Demo
  class SubjectURL
  end
end

```

When jumping into the console or RSpec, I never see this class load and end up with this error instead:

```ruby
NameError:
  uninitialized constant Demo::SubjectURL

```

When looking at the Zeitwork logs being printed straight to the terminal, I _should_ see the following:

```bash
Zeitwerk@demo: constant Demo::SubjectURL loaded from file demo/lib/demo/subject_url.rb

```

Instead I get no output because _I think_ by the time I attempt to configure the autoloader, it’s already been setup via Dry System/Hanami so my custom setting is being ignored.

Is this the wrong way to configure Zeitwerk within Hanami? What should I be doing different?

---

<div class="post-metadata">

**Author:** ![timriley](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/timriley/32/621_2.png) [@timriley](https://discourse.hanakai.org/u/timriley)\
**Post date:** [March 10, 2023, 10:09pm UTC](https://discourse.hanakai.org/t/should-zeitwerk-autoloader-be-configurable/807/2 "2023-03-10T22:09:50Z")

</div>

Hey @bkuhlmann, could you please try configuring the Hanami app’s own inflections instead of the Zeitwerk loader’s inflector? The app inflector is provided to Zeitwerk as part of our internal setup of Zeitwek, and that should do the trick.

---

<div class="post-metadata">

**Author:** ![timriley](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/timriley/32/621_2.png) [@timriley](https://discourse.hanakai.org/u/timriley)\
**Post date:** [March 10, 2023, 10:30pm UTC](https://discourse.hanakai.org/t/should-zeitwerk-autoloader-be-configurable/807/3 "2023-03-10T22:30:28Z")

</div>

See [this integration spec](https://github.com/hanami/hanami/blob/b73ad93534a2b5402d34dc365fe5fcbea52e8cbd/spec/integration/container/autoloader_spec.rb#L11) as a working example of the setup I described above.

---

<div class="post-metadata">

**Author:** ![bkuhlmann](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/bkuhlmann/32/475_2.png) [@bkuhlmann](https://discourse.hanakai.org/u/bkuhlmann)\
**Post date:** [March 10, 2023, 11:26pm UTC](https://discourse.hanakai.org/t/should-zeitwerk-autoloader-be-configurable/807/4 "2023-03-10T23:26:42Z")

</div>

Ah, thanks, that worked! Actually, I had tried using Dry Inflector earlier by using `inflections.acronym "SubjectURL"` but didn’t realize you only need to use `"URL"` as the acronym because I was thinking in terms of how Zeitwerk is designed to work and had assumed Dry Inflector worked similar so ended up trying work with Zeitwerk directly. Lesson learned. 😅
