forked from bofh/fetsite
FIX: Modulgruppen melden Fehler bei Studium blank
Der Fix inkludiert zwei Änderungen: erstens ist die Abfrage im Controller create jetzt mit find_by_id anstatt find, das behebt den hauptsächlichen Fehler. Zweitens hab ich ins modell studium_id als validation aufgenommen, ohne dem wird es nicht richtig als Fehler dargestellt.
This commit is contained in:
@@ -44,9 +44,9 @@ class ModulgruppenController < ApplicationController
|
||||
def create
|
||||
@modulgruppe = Modulgruppe.new(params[:modulgruppe])
|
||||
if !params[:studium_id].nil?
|
||||
@studium=Studium.find(params[:studium_id])
|
||||
@studium=Studium.find_by_id(params[:studium_id])
|
||||
else
|
||||
@studium=Studium.find(params[:modulgruppe][:studium_id])
|
||||
@studium=Studium.find_by_id(params[:modulgruppe][:studium_id])
|
||||
end
|
||||
respond_to do |format|
|
||||
if @modulgruppe.save
|
||||
|
||||
@@ -3,7 +3,8 @@ class Modulgruppe < ActiveRecord::Base
|
||||
belongs_to :studium, :foreign_key => "studium_id"
|
||||
has_and_belongs_to_many :moduls
|
||||
resourcify
|
||||
validates :studium, :presence=>true
|
||||
validates :studium_id, :presence => true
|
||||
validates :studium, :presence => true
|
||||
validates :name, :presence=>true,:uniqueness =>{:scope => :studium, :message => "Nur einmal je Studium erlaubt"}
|
||||
validates :phase, :numericality => { :only_integer => true },:inclusion => {:in => [1, 2, 3, 4], :message => "%{value} is not valid, choose phase 1 to 4"}, :presence=>true
|
||||
validates :typ, :inclusion => {:in => ["Pflicht","Vertiefungspflicht","Wahl"] }
|
||||
|
||||
Reference in New Issue
Block a user