Project

General

Profile

Actions

Refactor #34005

closed

Feature #29991: Enable Zeitwerk autoload mode for Rails 6+

Refactor #33886: Fix early loads of constants

Require middlewares properly

Added by Ondřej Ezr almost 3 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Rails
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

We require middlewares by `require_dependency`.

This is not exactly correct. I found a nice explanation about this https://ieftimov.com/post/writing-rails-middleware/

So we should put the middlewares in lib/middleware/foreman instead of lib/foreman/middleware and use Foreman::NameOfMiddleware and use

config.middleware.use "Foreman::NameOfMiddleware"
That way Rails will do it's magic and require the middlewares for us no need to do this explicitly.

We should just use regular require and be done with it, as a conclusion of the https://github.com/rails/rails/issues/25525 suggests.


Related issues 1 (0 open1 closed)

Related to Foreman - Refactor #34165: Require code from lib folderClosedLeos StejskalActions
Actions #1

Updated by Ondřej Ezr almost 3 years ago

  • Description updated (diff)
Actions #2

Updated by Ondřej Ezr almost 3 years ago

Might not be possible, I've added the middleware as string, but Rails did not do it's magic, it might have been removed, so we might need to just require it instead.

Actions #3

Updated by Ondřej Ezr almost 3 years ago

  • Description updated (diff)

Yeah this is not possible since Rails 5.

Actions #4

Updated by Ondřej Ezr almost 3 years ago

  • Description updated (diff)
Actions #5

Updated by Ondřej Ezr over 2 years ago

  • Status changed from New to Closed

Fixed in #34165

Actions #6

Updated by Ondřej Ezr over 2 years ago

Actions

Also available in: Atom PDF