[LRUG] [Chat] IronRuby

Pratik Naik pratik at thinkwares.com
Tue Jul 24 06:47:09 PDT 2007


> def create
>   @person = Person.new(params[:person])
>   @person.save!
>   redirect_to :index
> rescue
>   # validation failed, go back to form
>   redirect_to :new
> end

Actually, a better way to write that would be something like :

def create
 @person = Person.new(params[:person])
 @person.save!
 redirect_to :index
rescue ActiveRecord::RecordInvalid
  render :action => 'new'
end

Which I feel is a perfect way to write things.

"rescue Exception" - BAD
"rescue IKnowWhatExactlyWentWrong" - Perfect

-Pratik
--
http://m.onkey.org



More information about the Chat mailing list