From 2f0ed542062ddd592238e7a74ca0da2c1291f1b7 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 12 Oct 2010 20:34:49 +0100 Subject: [PATCH 1/1] Handle attempts to agree terms by users with validation errors better --- app/controllers/user_controller.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 -- 2.45.1