From d14700c51d692335f001a93c2f6b13b135783206 Mon Sep 17 00:00:00 2001 From: IN COMMON Collective Date: Thu, 8 Apr 2021 16:34:15 +0200 Subject: [FIX] Use form model to create/edit resources (fixes #4, fixes #5, refs #3) Since we must associate other models (e.g., classifications) to a Resource, we use a composite model to save all changes inside a database transaction. This approach makes it simpler to handle resources and their associations. Work remains to fix the geolocation and reverse geolocation to ensure these are in sync. --- app/helpers/resources_helper.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/resources_helper.rb b/app/helpers/resources_helper.rb index a949311..792a78a 100644 --- a/app/helpers/resources_helper.rb +++ b/app/helpers/resources_helper.rb @@ -4,13 +4,14 @@ module ResourcesHelper # Return a SELECT tag to choose a section in a given taxonomy - def section_select(taxonomy, selected = nil) + def section_select(taxonomy, selected = nil, options = {}) grouped_options = [] + tag_name = options[:name] || 'classification[section_ids]' taxonomy.categories.each do |c| grouped_options << [c.name, c.sections.map { |s| [s.name, s.id] }] end - select_tag('classification[section_ids]', grouped_options_for_select(grouped_options), selected: selected, multiple: true) + select_tag(tag_name, grouped_options_for_select(grouped_options, selected), multiple: true) end end -- cgit v1.2.3