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
Copy file name to clipboardExpand all lines: README.adoc
+19
Original file line number
Diff line number
Diff line change
@@ -1877,6 +1877,25 @@ freeze_time
1877
1877
1878
1878
If your projects depends on various external processes use https://github.com/ddollar/foreman[foreman] to manage them.
1879
1879
1880
+
== Code loading [[code-loading]]
1881
+
1882
+
=== Lazy load hooks
1883
+
1884
+
Use https://api.rubyonrails.org/classes/ActiveSupport/LazyLoadHooks.html[lazy load hooks] to patch Rails core classes, so they are not forcible loaded early.
1885
+
1886
+
[source,ruby]
1887
+
----
1888
+
# bad
1889
+
ActiveRecord::Base.include(MyClass)
1890
+
1891
+
# good
1892
+
ActiveSupport.on_load(:active_record) { include MyClass }
1893
+
----
1894
+
1895
+
=== Zeitwerk check in CI
1896
+
1897
+
Run `bin/rails zeitwerk:check` in your CI to ensure all application code is eager loaded correctly like in production.
1898
+
1880
1899
== Further Reading
1881
1900
1882
1901
There are a few excellent resources on Rails style, that you should consider if you have time to spare:
0 commit comments