We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 87be762 commit 8c7e490Copy full SHA for 8c7e490
lib/closure_tree/support.rb
@@ -43,6 +43,10 @@ def hierarchy_class_for_model
43
# Rails 8.1+ requires an implicit_order_column for models without a primary key
44
self.implicit_order_column = 'ancestor_id'
45
46
+ # Rails uses the primary key to correctly match associations when using a join to preload (e.g. via `eager_load`).
47
+ # The migration generator adds a unique index across these three columns so this is safe.
48
+ self.primary_key = [:ancestor_id, :descendant_id, :generations]
49
+
50
belongs_to :ancestor, class_name: model_class_name
51
belongs_to :descendant, class_name: model_class_name
52
def ==(other)
0 commit comments