summaryrefslogtreecommitdiff
path: root/users/app/controllers
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-12-18 13:41:41 +0100
committerAzul <azul@leap.se>2012-12-18 13:41:41 +0100
commit285b23f39765d8346a658a81eca8b70d70b3e9bf (patch)
treeddb8f4d433c6f0461f7832ad08475b9a5bae99b2 /users/app/controllers
parent6e8a45145722c12dee4d15b33cc28d2b09881e1a (diff)
refactored email_alias creation and validation
using CouchRests user.email_aliases.build so the casted_by method is set in the alias Used this to move the validations into the alias itself. This is where they belong and allows us to render the errors inline along the email field they belong to.
Diffstat (limited to 'users/app/controllers')
-rw-r--r--users/app/controllers/users_controller.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/users/app/controllers/users_controller.rb b/users/app/controllers/users_controller.rb
index 8ba6a7b..5c6767c 100644
--- a/users/app/controllers/users_controller.rb
+++ b/users/app/controllers/users_controller.rb
@@ -27,16 +27,16 @@ class UsersController < ApplicationController
end
def edit
+ @email_alias = LocalEmail.new
end
def update
@user.attributes = params[:user]
+ @email_alias = @user.email_aliases.last
if @user.changed? and @user.save
flash[:notice] = t(:user_updated_successfully)
- else
- flash.now[:error] = @user.errors.full_messages.to_sentence
end
- respond_with @user.reload, :location => edit_user_path(@user, :anchor => :email)
+ respond_with @user, :location => edit_user_path(@user, :anchor => :email)
end
def destroy