From 42312b6bc9ef8509316611e9b5c424b56caec428 Mon Sep 17 00:00:00 2001 From: Andreas Stephanides Date: Wed, 2 Apr 2014 15:32:30 +0200 Subject: [PATCH] fix save modulgruppen --- app/controllers/moduls_controller.rb | 5 +---- app/models/modulgruppe.rb | 4 +++- app/views/moduls/_form.html.erb | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/controllers/moduls_controller.rb b/app/controllers/moduls_controller.rb index b64bd20..3398a66 100755 --- a/app/controllers/moduls_controller.rb +++ b/app/controllers/moduls_controller.rb @@ -44,14 +44,11 @@ class ModulsController < ApplicationController end end def edit_lvas - - @lvas = @modul.lvas + @lvas = @modul.lvas @semester = @modul.modulgruppen.flatten.map(&:studium).map(&:semester).flatten.uniq end def update_lvas - - @semester = @modul.modulgruppen.flatten.map(&:studium).map(&:semester).flatten.uniq @newlvas=Lva.update_multiple_with_modul(params["lvas"],@modul) @lvas=@newlvas diff --git a/app/models/modulgruppe.rb b/app/models/modulgruppe.rb index 6382f64..50feb0a 100755 --- a/app/models/modulgruppe.rb +++ b/app/models/modulgruppe.rb @@ -25,7 +25,9 @@ class Modulgruppe < ActiveRecord::Base validates :phase, :inclusion => {:in => [1, 2, 3, 4]} validates :typ, :inclusion => {:in => ["Pflicht","Vertiefungspflicht","Wahl"] } translates :desc, :versioning =>true,:fallbacks_for_empty_translations => true - + def long_name + self.studium_name + ": "+ name + end def studium_name self.studium.nil? ? "Kein Studium vorhanden" : self.studium.name end diff --git a/app/views/moduls/_form.html.erb b/app/views/moduls/_form.html.erb index c21d7c3..d3af507 100755 --- a/app/views/moduls/_form.html.erb +++ b/app/views/moduls/_form.html.erb @@ -1,6 +1,5 @@
<%= semantic_form_for @modul do |f| %> - <%= f.inputs do %>
@@ -24,7 +23,7 @@
- <%= f.input :modulgruppen,:as => :check_boxes, :collection => Hash[Modulgruppe.all.map{|m| [m.studium.name + " " + m.name,m.id]}.sort] %> + <%= f.input :modulgruppen, :as => :check_boxes, :member_label=>:long_name, :collection => Modulgruppe.all %>