Add filter by goal

This commit is contained in:
Javi Martín
2020-12-17 19:13:48 +01:00
parent 791ba73e12
commit c9362ffeb4
10 changed files with 101 additions and 14 deletions

View File

@@ -12,6 +12,14 @@ module SDG::Relatable
end
end
class_methods do
def by_goal(code)
return all if code.blank?
joins(:sdg_goals).merge(SDG::Goal.where(code: code))
end
end
def related_sdgs
sdg_relations.map(&:related_sdg)
end