On create error, should I render `new` or redirect to `new`?

Viewed 2009

Suppose I have something like this:

def new
  @user = User.new
end
def create
  @user = User.create(params[:user])
  if @user.save
    flash[:notice] = 'User created'
    redirect_to :action => 'list'
  else
    flash[:error] = 'Some error here!'
    render 'new'
  end
end

I think the code is clear.
The problem here is, when the @user object is not saved successfully, should I render new (as above) or should redirect to new?

I know if redirect to new the data input by the user is lost, but if I render new, the URL will be /users/create instead of /users/new (which is ugly!).

1 Answers
Related