From: Tom Hughes Date: Tue, 12 Oct 2010 19:34:49 +0000 (+0100) Subject: Handle attempts to agree terms by users with validation errors better X-Git-Tag: live~6260^2~1 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/2f0ed542062ddd592238e7a74ca0da2c1291f1b7?ds=sidebyside Handle attempts to agree terms by users with validation errors better --- diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index e5a2f04bd..c8603afec 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -32,7 +32,12 @@ class UserController < ApplicationController if @user if @user.invalid? - render :action => :new + if @user.new_record? + render :action => :new + else + flash[:errors] = @user.errors + redirect_to :action => :account, :display_name => @user.display_name + end elsif @user.terms_agreed? redirect_to :action => :account, :display_name => @user.display_name end @@ -123,7 +128,7 @@ class UserController < ApplicationController else if flash[:errors] flash[:errors].each do |attr,msg| - attr = "new_email" if attr == "email" + attr = "new_email" if attr == "email" and !@user.new_email.nil? @user.errors.add(attr,msg) end end