diff --git a/README.adoc b/README.adoc index 7fc68d2..525f6d9 100644 --- a/README.adoc +++ b/README.adoc @@ -1877,6 +1877,25 @@ freeze_time If your projects depends on various external processes use https://github.com/ddollar/foreman[foreman] to manage them. +== Code loading [[code-loading]] + +=== Lazy load hooks + +Use https://api.rubyonrails.org/classes/ActiveSupport/LazyLoadHooks.html[lazy load hooks] to patch Rails core classes, so they are not forcible loaded early. + +[source,ruby] +---- +# bad +ActiveRecord::Base.include(MyClass) + +# good +ActiveSupport.on_load(:active_record) { include MyClass } +---- + +=== Zeitwerk check in CI + +Add running `bin/rails zeitwerk:check` to your CI, this ensures all application code is eager loaded like in production. + == Further Reading There are a few excellent resources on Rails style, that you should consider if you have time to spare: