Follow Rails autoloading conventions #532
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Depends on #530, because it won't pass specs without.
Thank you for this excellent gem, which we're using happily in production.
I encountered a conflict between
audited
and another gem which I believe is caused by the way audited hooks into Rails core classes. A minimal app displaying the behaviour is here: https://github.com/duncanjbrown/audited-bug. The behaviour is outlined on a rubyonrails-talk thread here: https://discuss.rubyonrails.org/t/understanding-a-conflict-between-two-activesupport-on-load-calls/74836.Where an
on_load
reference is required to a non-ActiveSupport class (such asActionController::API
), wrapping the initialization code in a properrailtie
prevents the weirdness I see in the above app. As far as I can tell this is the correct way to inject this code and it doesn't seem to breakaudited
, which is why I'm submitting this PR.While investigating this I learned that the current guidance (https://edgeguides.rubyonrails.org/engines.html#avoid-loading-rails-frameworks) it is best practice to extend core classes by hooking into ActiveSupport.on_load hooks, so this PR includes a change to the way
audited
does that, too.