From 285b23f39765d8346a658a81eca8b70d70b3e9bf Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 18 Dec 2012 13:41:41 +0100 Subject: 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. --- users/app/controllers/users_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'users/app/controllers') 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 -- cgit v1.2.3