Forum: Ruby on Rails RE: Doubts on validation

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
5190273ecab4b93b2d4e7529dcc1f7c6?d=identicon&s=25 unknown (Guest)
on 2006-02-03 23:09
(Received via mailing list)
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
This topic is locked and can not be replied to.