Move to crops helper

This commit is contained in:
Daniel O'Connor
2025-11-30 02:59:04 +00:00
parent d570b27a7b
commit 38aa245290

View File

@@ -1,12 +1,12 @@
# frozen_string_literal: true
module CropsHelper
def crop_or_parent(crop, attribute)
default = crop.send(attribute)
return default if default.present?
parent = crop
while parent = parent.parent do
while parent = parent.parent
return parent.send(attribute) if parent&.send(attribute).present?
end
@@ -38,4 +38,13 @@ module CropsHelper
match = url.match(regex)
match[1] if match
end
def jsonld_data(crop)
{
'@context': "https://schema.org",
'@type': "BioChemEntity",
name: crop.name,
taxonomicRange: crop.scientific_names.map(&:name)
}
end
end