Skip to content

Instantly share code, notes, and snippets.

@stilist
Created July 10, 2024 18:31
Show Gist options
  • Save stilist/58da83da45e0ba1c2cdd4970035e3827 to your computer and use it in GitHub Desktop.
Save stilist/58da83da45e0ba1c2cdd4970035e3827 to your computer and use it in GitHub Desktop.
Monkeypatch relations into Publify Blog model
diff --git a/config/initializers/model_extensions.rb b/config/initializers/model_extensions.rb
new file mode 100644
index 000000000..2db532ba9
--- /dev/null
+++ b/config/initializers/model_extensions.rb
@@ -0,0 +1 @@
+require "blog_extension"
diff --git a/lib/blog_extension.rb b/lib/blog_extension.rb
new file mode 100644
index 000000000..01fbcf5b3
--- /dev/null
+++ b/lib/blog_extension.rb
@@ -0,0 +1,9 @@
+module BlogExtension
+ extend ActiveSupport::Concern
+
+ included do
+ has_many :xyz
+ end
+end
+
+Blog.include BlogExtension
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment