mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-25 09:19:15 -04:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
313e240eb9 | ||
|
|
14aa673440 | ||
|
|
cef23b8212 | ||
|
|
3b45dca6e2 | ||
|
|
9060c45aed | ||
|
|
d4401b402a |
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user