Rails create action is redirecting to index when i

2019-04-24 12:30发布

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

1条回答
三岁会撩人
2楼-- · 2019-04-24 12:54

I think you want to say

redirect_to :action => 'new'
查看更多
登录 后发表回答