You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because this hook is only called for classes that extend Rails::Railtie directly, extending Lograge::Railtie will result in Lograge::Railtie itself getting registered, but not its subclass. Some Railties that are designed for extension (e.g. Rails::Engine itself) deal with this by adding their owninherited hook which calls super.
I've worked this by modifying Railtie.subclasses directly, but it feels a bit hacky.
moduleMyModuleclassRailtie < Lograge::RailtieRails::Railtie.subclasses.delete(Lograge::Railtie)Rails::Railtie.subclasses << self# ...rest of class
At any rate, IDK if this is something Lograge is interested in supporting, but if not, it might be nice to add a note to the documentation.
System info
Lograge version: 0.11.2
Rails version: 6.0.3.4
RVM version: 1.29.10
Ruby version: 2.7.1p83
OS: macOS Catalina (10.15.7)
The text was updated successfully, but these errors were encountered:
(It's probably not strictly necessary for me to extend Lograge::Railtie in any case, but it seems a clearer way of documenting "this Railtie also initializes Lograge" than just calling require 'lograge' at the top without explicitly calling any Lograge code.)
FWIW, the workaround above no longer works in Rails 6.1, which removes the subclasses array and instead changes Railtie to extend ActiveSupport::DescendantsTracker.
Rails::Railtie
depends on aninherited
hook to build the list of Railtie classes (Rails::Railties
,Rails::Engine.railties
) that should be initialized and/or invoked at runtime (see this section inRails::Application
).Because this hook is only called for classes that extend
Rails::Railtie
directly, extendingLograge::Railtie
will result inLograge::Railtie
itself getting registered, but not its subclass. SomeRailties
that are designed for extension (e.g.Rails::Engine
itself) deal with this by adding their owninherited
hook which callssuper
.I've worked this by modifying
Railtie.subclasses
directly, but it feels a bit hacky.At any rate, IDK if this is something Lograge is interested in supporting, but if not, it might be nice to add a note to the documentation.
System info
The text was updated successfully, but these errors were encountered: