RE: Doubts on validation


#1

Hi adam,
Thanks for responding to my question. I did not write the controller
properly. My bad. I did not have the else part.
Part of the learning process!!

def create
begin
@student = Student.new(@params[:student])
if @student.save
flash[:notice] = ‘Student was successfully created.’
redirect_to :action => ‘list’
else
@offices = Office.find_all
@programs = Program.find_all
@courses = Course.find_all
render :action => ‘new’
end
rescue
flash[‘notice’] = ‘Item could not be saved.’
redirect_to :action => ‘new’
end
end

Thanks
Silvy