views:

22

answers:

1

If I submit a new user form with errors, it redirects to the index page and then renders the new page on top of it. In the controller I specify that it should just render the new action so that the user can see/fix their errors and resubmit. Is there something obvious that I am missing?

Here's the create action in my controller code:

def create
  @user = User.new(params[:user])
  @user.role = "owner"

  if @user.save
    flash[:notice] = "Registration successful!"
  else
    flash.now[:notice] = "You have errors!"
    render :new
  end
end
A: 

I think you want to say

redirect_to :action => 'new'
Ladlestein
Not necessarily. They may want to re-render the form with the values given by the user. render :new ought to be fine here.
Dave Sims
Yeah redirect works but it doesn't show the errors or anything then.
Matt