Forum: Ruby on Rails What do u think of this cool technique?? Can you see a flaw?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Cd8c9864d88bcafc164d8fdb820cc451?d=identicon&s=25 Chris Richards (chris)
on 2007-07-12 10:37
I saw this somewhere and thought it looked damn nice :

  def new
    @user =

  def create
    @user =[:user])!
    self.current_user = @user
    flash[:notice] = "Thanks for signing up!"
  rescue ActiveRecord::RecordInvalid
    render :action => 'new'

so save! returns an exception instead of false if it couldn't happen,
which is then caught with the rescue block.

It gets rid of an if, else block.

Can  anyone see a flaw?  or a reason why this might be crappy?

This topic is locked and can not be replied to.