controller icon indicating copy to clipboard operation
controller copied to clipboard

When configuration public directory isn't set, fallback to default value

Open jodosha opened this issue 4 years ago • 2 comments

https://github.com/hanami/hanami-2-application-template/commit/9a23a1b331dc0ee7629099d0d6320a3f341e4885 crashes when I try to run the specs:


The current implementation of Hanami::Action::Configuration#public_directory is:

def public_directory
  root_directory.join(super).to_s
end

For the App Template super returns nil, which makes the Pathname#join (root_directory is an instance of Pathname) to crash.


This fix aims to fallback to the default value if super returns nil.


EDIT: ⚠️ I'm not sure this is the right approach. Given the default value is assigned via dry-configurable, I would have expected super to return the default value, instead of nil.

jodosha avatar Aug 09 '21 13:08 jodosha

If you set if to nil dry-configurable will return nil even if there's a default as it assumes that was intentional (IIRC - has been a while since I delved into ts code). ~~Can you share a sample where this became an issue?~~ (RTFMessage, mereghost).

I've removed the assignment and everything works as expected. I'll see if I spot anything weird on the template.

mereghost avatar Aug 10 '21 12:08 mereghost

For the App Template super returns nil.

Where is it set on the App Template? I looked into both the App Template and Hanami itself, and I couldn't find it.

waiting-for-dev avatar Aug 14 '21 05:08 waiting-for-dev