Fix task validation #16

This commit is contained in:
Julius 2012-11-12 20:14:06 +01:00
parent 95efe554fc
commit e561ddb064
2 changed files with 3 additions and 4 deletions

View file

@ -17,14 +17,13 @@ class TasksController < ApplicationController
def create def create
@task = Task.new(params[:task]) @task = Task.new(params[:task])
if @task.errors.empty? if @task.save
@task.save
flash[:notice] = "Aufgabe wurde erstellt" flash[:notice] = "Aufgabe wurde erstellt"
if @task.workgroup if @task.workgroup
redirect_to :action => "workgroup", :id => @task.workgroup redirect_to :action => "workgroup", :id => @task.workgroup
else else
redirect_to :action => "index" redirect_to :action => "index"
end end
else else
render :template => "tasks/new" render :template => "tasks/new"
end end

View file

@ -11,7 +11,7 @@ class Task < ActiveRecord::Base
attr_protected :users attr_protected :users
validates_length_of :name, :minimum => 3 validates_length_of :name, :minimum => 3
validates_numericality_of :duration, :required_users, :only_integer => true, :greater_than => 1 validates_numericality_of :duration, :required_users, :only_integer => true, :greater_than_or_equal_to => 1
after_save :update_ordergroup_stats after_save :update_ordergroup_stats