Compare commits

...

6 Commits

Author SHA1 Message Date
Daniel O'Connor
313e240eb9 Merge pull request #4337 from Growstuff/recursive-fallback
More recursive companions
2025-11-29 19:39:31 +10:30
Daniel O'Connor
14aa673440 Merge branch 'mainline' into dev 2025-11-29 19:31:17 +10:30
Daniel O'Connor
cef23b8212 More recursive companions 2025-11-29 08:55:29 +00:00
Daniel O'Connor
3b45dca6e2 Merge pull request #4335 from Growstuff/recursive-fallback
Recursive parent lookup
2025-11-29 19:17:12 +10:30
Daniel O'Connor
9060c45aed Recursive parent lookup 2025-11-29 08:36:43 +00:00
Daniel O'Connor
d4401b402a Merge pull request #4334 from Growstuff/dev
release 75
2025-11-29 18:21:22 +10:30
2 changed files with 4 additions and 2 deletions

View File

@@ -5,7 +5,9 @@ module CropsHelper
def crop_or_parent(crop, attribute)
default = crop.send(attribute)
return default if default.present?
return crop.parent.send(attribute) if crop.parent&.send(attribute).present?
while parent = crop.parent do
return parent.send(attribute) if parent&.send(attribute).present?
end
# For scopes, arrays, etc return the empty value
default

View File

@@ -162,7 +162,7 @@ class Crop < ApplicationRecord
def all_companions
return companions unless parent
(companions + parent.companions).uniq
(companions + parent.all_companions).uniq
end
before_destroy :destroy_reverse_companionships