From b90ce01890907d1c7f46f46bafcef416570a4c4b Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 17 Dec 2012 17:48:39 +0100 Subject: enabled destroying email aliases - no ajax yet. --- users/app/controllers/email_aliases_controller.rb | 25 +++-------------------- users/app/models/email.rb | 8 ++++++++ users/app/models/user.rb | 4 ++++ users/app/views/emails/_email.html.haml | 3 ++- users/config/locales/en.yml | 1 + users/config/routes.rb | 2 +- 6 files changed, 19 insertions(+), 24 deletions(-) diff --git a/users/app/controllers/email_aliases_controller.rb b/users/app/controllers/email_aliases_controller.rb index 751df85..3b0d5ac 100644 --- a/users/app/controllers/email_aliases_controller.rb +++ b/users/app/controllers/email_aliases_controller.rb @@ -4,29 +4,10 @@ class EmailAliasesController < ApplicationController respond_to :html - # get a list of email aliases for the given user? - def index - @aliases = @user.email_aliases - respond_with @aliases - end - - def create - @alias = @user.add_email_alias(params[:email_alias]) - flash[:notice] = t(:email_alias_created_successfully) unless @alias.errors - respond_with @alias, :location => edit_user_path(@user, :anchor => :email) - end - - def update - @alias = @user.get_email_alias(params[:id]) - @alias.set_email(params[:email_alias]) - flash[:notice] = t(:email_alias_updated_successfully) unless @alias.errors - respond_with @alias, :location => edit_user_path(@user, :anchor => :email) - end - def destroy - @alias = @user.get_email_alias(params[:id]) - flash[:notice] = t(:email_alias_destroyed_successfully) - @alias.destroy + @alias = @user.email_aliases.delete(params[:id]) + @user.save + flash[:notice] = t(:email_alias_destroyed_successfully, :alias => @alias) redirect_to edit_user_path(@user, :anchor => :email) end diff --git a/users/app/models/email.rb b/users/app/models/email.rb index 4b01838..0745fda 100644 --- a/users/app/models/email.rb +++ b/users/app/models/email.rb @@ -14,4 +14,12 @@ class Email def to_s email end + + def ==(other) + other.is_a?(String) ? self.email == other : super + end + + def to_param + email + end end diff --git a/users/app/models/user.rb b/users/app/models/user.rb index 10f358d..d66b0e9 100644 --- a/users/app/models/user.rb +++ b/users/app/models/user.rb @@ -45,6 +45,7 @@ class User < CouchRest::Model::Base view :by_login view :by_created_at view :by_email + view :by_email_alias, :map => <<-EOJS function(doc) { @@ -56,6 +57,7 @@ class User < CouchRest::Model::Base }); } EOJS + view :by_email_or_alias, :map => <<-EOJS function(doc) { @@ -70,6 +72,7 @@ class User < CouchRest::Model::Base }); } EOJS + end class << self @@ -127,6 +130,7 @@ class User < CouchRest::Model::Base end end + ## # Validation Functions ## diff --git a/users/app/views/emails/_email.html.haml b/users/app/views/emails/_email.html.haml index f182ed9..f5eb2d0 100644 --- a/users/app/views/emails/_email.html.haml +++ b/users/app/views/emails/_email.html.haml @@ -1,4 +1,5 @@ %li.pull-right %code= email - %i.icon-remove + = link_to(user_email_alias_path(@user, email), :method => :delete) do + %i.icon-remove .clearfix diff --git a/users/config/locales/en.yml b/users/config/locales/en.yml index d068e70..3c71e7e 100644 --- a/users/config/locales/en.yml +++ b/users/config/locales/en.yml @@ -15,6 +15,7 @@ en: add_email_alias: "Add email alias" user_updated_successfully: "Settings have been updated successfully." user_created_successfully: "Successfully created your account." + email_alias_destroyed_successfully: "Successfully removed the alias '%{alias}'." activemodel: models: diff --git a/users/config/routes.rb b/users/config/routes.rb index 3c5fb73..8985502 100644 --- a/users/config/routes.rb +++ b/users/config/routes.rb @@ -11,7 +11,7 @@ Rails.application.routes.draw do get "signup" => "users#new", :as => "signup" resources :users do - resources :email_aliases + resources :email_aliases, :only => [:destroy], :id => /.*/ end end -- cgit v1.2.3 From be2d8fbd65f4ed2e1e97b19a3322da20e2fb4eda Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 17 Dec 2012 19:03:45 +0100 Subject: activate email tab after changing email settings --- users/app/assets/javascripts/users.js.coffee | 8 ++++++++ users/app/controllers/users_controller.rb | 2 +- users/app/helpers/users_helper.rb | 5 +++++ users/app/views/users/edit.html.haml | 4 ++-- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/users/app/assets/javascripts/users.js.coffee b/users/app/assets/javascripts/users.js.coffee index 0c1fb55..86bacee 100644 --- a/users/app/assets/javascripts/users.js.coffee +++ b/users/app/assets/javascripts/users.js.coffee @@ -24,7 +24,15 @@ srp.error = (message) -> pollUsers = (query, process) -> $.get( "/users.json", query: query).done(process) +followLocationHash = -> + location = window.location.hash + if location + href_select = 'a[href="' + location + '"]' + link = $(href_select) + link.tab('show') if link + $(document).ready -> + followLocationHash() $('#new_user').submit preventDefault $('#new_user').submit srp.signup $('#new_session').submit preventDefault diff --git a/users/app/controllers/users_controller.rb b/users/app/controllers/users_controller.rb index 811e8e5..feb66c8 100644 --- a/users/app/controllers/users_controller.rb +++ b/users/app/controllers/users_controller.rb @@ -36,7 +36,7 @@ class UsersController < ApplicationController else flash[:error] = @user.errors.full_messages end - respond_with @user, :location => edit_user_path(@user) + respond_with @user, :location => edit_user_path(@user, :anchor => :email) end def destroy diff --git a/users/app/helpers/users_helper.rb b/users/app/helpers/users_helper.rb index b017bca..6d76d6f 100644 --- a/users/app/helpers/users_helper.rb +++ b/users/app/helpers/users_helper.rb @@ -29,4 +29,9 @@ module UsersHelper classes << (@user.new_record? ? 'new' : 'edit') classes.compact end + + def email_settings? + params[:user] && + params[:user].keys.detect{|key| key.index('email')} + end end diff --git a/users/app/views/users/edit.html.haml b/users/app/views/users/edit.html.haml index 92ab71b..a2a0942 100644 --- a/users/app/views/users/edit.html.haml +++ b/users/app/views/users/edit.html.haml @@ -1,9 +1,9 @@ .span8.offset2 %h2=t :settings %ul.nav.nav-tabs - %li.active + %li{:class => email_settings? ? :inactive : :active} %a{:href => '#account', 'data-toggle' => 'tab'}Account - %li + %li{:class => email_settings? ? :active : :inactive} %a{:href => '#email', 'data-toggle' => 'tab'}Email .tab-content -- cgit v1.2.3 From 6393a9d705f181bd7f81270b01448ae93acb96e5 Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 18 Dec 2012 02:51:18 +0100 Subject: display errors on email tab properly still needs a bit of refactoring in the view --- users/app/controllers/users_controller.rb | 4 ++-- users/app/views/users/edit.html.haml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/users/app/controllers/users_controller.rb b/users/app/controllers/users_controller.rb index feb66c8..8ba6a7b 100644 --- a/users/app/controllers/users_controller.rb +++ b/users/app/controllers/users_controller.rb @@ -34,9 +34,9 @@ class UsersController < ApplicationController if @user.changed? and @user.save flash[:notice] = t(:user_updated_successfully) else - flash[:error] = @user.errors.full_messages + flash.now[:error] = @user.errors.full_messages.to_sentence end - respond_with @user, :location => edit_user_path(@user, :anchor => :email) + respond_with @user.reload, :location => edit_user_path(@user, :anchor => :email) end def destroy diff --git a/users/app/views/users/edit.html.haml b/users/app/views/users/edit.html.haml index a2a0942..8fc2cab 100644 --- a/users/app/views/users/edit.html.haml +++ b/users/app/views/users/edit.html.haml @@ -7,11 +7,11 @@ %a{:href => '#email', 'data-toggle' => 'tab'}Email .tab-content - .tab-pane.active#account + .tab-pane#account{:class => email_settings? ? :inactive : :active} = user_form_with 'login_field', :legend => :change_login = user_form_with 'password_fields', :legend => :change_password = render 'cancel_account' if @user == current_user - .tab-pane#email + .tab-pane#email{:class => email_settings? ? :active : :inactive} = user_form_with 'email_field', :legend => :set_email_address = user_form_with 'email_forward_field', :legend => :forward_email = user_form_with 'email_aliases', :legend => :add_email_alias -- cgit v1.2.3 From 6e8a45145722c12dee4d15b33cc28d2b09881e1a Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 18 Dec 2012 11:46:58 +0100 Subject: adjusted tests - we now reload the user so invalid records are cleared Actually that might not be the best idea. Issue at hand was that invalid email aliases were getting displayed when rendering the edit form again. We probably want to solve this different. --- users/test/functional/users_controller_test.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/users/test/functional/users_controller_test.rb b/users/test/functional/users_controller_test.rb index ce17500..b31a642 100644 --- a/users/test/functional/users_controller_test.rb +++ b/users/test/functional/users_controller_test.rb @@ -45,11 +45,12 @@ class UsersControllerTest < ActionController::TestCase assert_equal user, assigns[:user] end - test "should process updated params" do + test "user can change settings" do user = find_record User user.expects(:attributes=).with(user.params) user.expects(:changed?).returns(true) user.expects(:save).returns(true) + user.expects(:reload).returns(user) login user put :update, :user => user.params, :id => user.id, :format => :json @@ -64,6 +65,7 @@ class UsersControllerTest < ActionController::TestCase user.expects(:attributes=).with(user.params) user.expects(:changed?).returns(true) user.expects(:save).returns(true) + user.expects(:reload).returns(user) login :is_admin? => true put :update, :user => user.params, :id => user.id, :format => :json -- cgit v1.2.3 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 +++--- users/app/models/local_email.rb | 21 ++++++++++++++++++++- users/app/models/user.rb | 26 +++++--------------------- users/app/views/emails/_email.html.haml | 11 ++++++----- users/app/views/users/_email_aliases.html.haml | 2 +- users/test/unit/email_aliases_test.rb | 11 ++++++----- users/test/unit/email_test.rb | 6 +++--- 7 files changed, 44 insertions(+), 39 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 diff --git a/users/app/models/local_email.rb b/users/app/models/local_email.rb index 7cca4f4..c654fcb 100644 --- a/users/app/models/local_email.rb +++ b/users/app/models/local_email.rb @@ -1,6 +1,9 @@ class LocalEmail < Email validate :unique_on_server + validate :unique_alias_for_user + validate :differs_from_main_email + validates :casted_by, :presence => true def to_partial_path "emails/email" @@ -9,7 +12,23 @@ class LocalEmail < Email def unique_on_server has_email = User.find_by_email_or_alias(email) if has_email && has_email != self.base_doc - errors.add(:email, "has already been taken") + errors.add :email, "has already been taken" end end + + def unique_alias_for_user + aliases = self.casted_by.email_aliases + if aliases.select{|a|a.email == self.email}.count > 1 + errors.add :email, "is already your alias" + end + end + + def differs_from_main_email + user = self.casted_by + if user.email == self.email + errors.add :email, "may not be the same as your email address" + end + end + + end diff --git a/users/app/models/user.rb b/users/app/models/user.rb index d66b0e9..0773f28 100644 --- a/users/app/models/user.rb +++ b/users/app/models/user.rb @@ -35,9 +35,7 @@ class User < CouchRest::Model::Base validates :email_forward, :format => { :with => /\A(([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,}))?\Z/, :message => "needs to be a valid email address"} - validate :no_duplicate_email_aliases - - validate :email_aliases_differ_from_email + validate :email_differs_from_email_aliases timestamps! @@ -117,34 +115,20 @@ class User < CouchRest::Model::Base APP_CONFIG['admins'].include? self.login end - def add_email_alias(email) - email = LocalEmail.new(email) unless email.is_a? Email - email_aliases << email - end - # this currently only adds the first email address submitted. # All the ui needs for now. def email_aliases_attributes=(attrs) - if attrs && attrs.values.first - add_email_alias attrs.values.first - end + email_aliases.build(attrs.values.first) if attrs end - ## # Validation Functions ## - # TODO: How do we handle these errors? - def no_duplicate_email_aliases - if email_aliases.count != email_aliases.map(&:email).uniq.count - errors.add(:email_aliases, "include a duplicate") - end - end - - def email_aliases_differ_from_email + def email_differs_from_email_aliases + return if email_aliases.last.errors.any? if email_aliases.map(&:email).include?(email) - errors.add(:email_aliases, "include the original email address") + errors.add(:email, "may not be the same as an alias") end end diff --git a/users/app/views/emails/_email.html.haml b/users/app/views/emails/_email.html.haml index f5eb2d0..3feb6f0 100644 --- a/users/app/views/emails/_email.html.haml +++ b/users/app/views/emails/_email.html.haml @@ -1,5 +1,6 @@ -%li.pull-right - %code= email - = link_to(user_email_alias_path(@user, email), :method => :delete) do - %i.icon-remove -.clearfix +- if email.valid? + %li.pull-right + %code= email + = link_to(user_email_alias_path(@user, email), :method => :delete) do + %i.icon-remove + .clearfix diff --git a/users/app/views/users/_email_aliases.html.haml b/users/app/views/users/_email_aliases.html.haml index 646480e..121acc4 100644 --- a/users/app/views/users/_email_aliases.html.haml +++ b/users/app/views/users/_email_aliases.html.haml @@ -2,5 +2,5 @@ %ul.unstyled =render @user.email_aliases .clearfix -= f.simple_fields_for :email_aliases, Email.new do |e| += f.simple_fields_for :email_aliases, @email_alias do |e| = e.input :email, :placeholder => "alias@#{request.domain}" diff --git a/users/test/unit/email_aliases_test.rb b/users/test/unit/email_aliases_test.rb index 762aaea..f680ac6 100644 --- a/users/test/unit/email_aliases_test.rb +++ b/users/test/unit/email_aliases_test.rb @@ -22,7 +22,7 @@ class EmailAliasTest < ActiveSupport::TestCase test "adding email alias directly" do email_alias = "valid_alias@domain.net" - @user.add_email_alias(email_alias) + @user.email_aliases.build :email => email_alias assert @user.changed? assert @user.save assert_equal email_alias, @user.reload.email_aliases.first.to_s @@ -30,10 +30,11 @@ class EmailAliasTest < ActiveSupport::TestCase test "duplicated email aliases are invalid" do email_alias = "valid_alias@domain.net" - @user.add_email_alias(email_alias) + @user.email_aliases.build :email => email_alias @user.save # add again - @user.add_email_alias(email_alias) + email_alias = @user.email_aliases.build :email => email_alias + assert !email_alias.valid? assert @user.changed? assert !@user.valid? end @@ -41,14 +42,14 @@ class EmailAliasTest < ActiveSupport::TestCase test "email is invalid as email alias" do email_alias = "valid_alias@domain.net" @user.email = email_alias - @user.add_email_alias(email_alias) + @user.email_aliases.build :email => email_alias assert @user.changed? assert !@user.valid? end test "find user by email alias" do email_alias = "valid_alias@domain.net" - @user.add_email_alias(email_alias) + @user.email_aliases.build :email => email_alias assert @user.save assert_equal @user, User.find_by_email_or_alias(email_alias) assert_equal @user, User.find_by_email_alias(email_alias) diff --git a/users/test/unit/email_test.rb b/users/test/unit/email_test.rb index 1e216d6..5aa2b11 100644 --- a/users/test/unit/email_test.rb +++ b/users/test/unit/email_test.rb @@ -20,9 +20,9 @@ class EmailTest < ActiveSupport::TestCase test "email aliases need to be unique" do email_alias = "valid_alias@domain.net" - @other_user.add_email_alias email_alias + @other_user.email_aliases.build :email => email_alias @other_user.save - @user.add_email_alias email_alias + @user.email_aliases.build :email => email_alias assert @user.changed? assert !@user.save # TODO handle errors @@ -32,7 +32,7 @@ class EmailTest < ActiveSupport::TestCase email_alias = "valid_alias@domain.net" @other_user.email = email_alias @other_user.save - @user.add_email_alias email_alias + @user.email_aliases.build :email => email_alias assert @user.changed? assert !@user.save end -- cgit v1.2.3 From 76904d3f677520eb191a90f2abb15b9df5fd8ae9 Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 18 Dec 2012 14:02:31 +0100 Subject: make sure we have email_aliases at all before testing for an error on the last --- users/app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/users/app/models/user.rb b/users/app/models/user.rb index 0773f28..1999a28 100644 --- a/users/app/models/user.rb +++ b/users/app/models/user.rb @@ -126,7 +126,7 @@ class User < CouchRest::Model::Base ## def email_differs_from_email_aliases - return if email_aliases.last.errors.any? + return if email_aliases.any? and email_aliases.last.errors.any? if email_aliases.map(&:email).include?(email) errors.add(:email, "may not be the same as an alias") end -- cgit v1.2.3 From 5a35873f8a12915d44cfa77239d094960ce6971e Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 18 Dec 2012 14:05:28 +0100 Subject: only destroy user that has been persisted in teardown --- users/test/unit/email_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/users/test/unit/email_test.rb b/users/test/unit/email_test.rb index 5aa2b11..6f9beaa 100644 --- a/users/test/unit/email_test.rb +++ b/users/test/unit/email_test.rb @@ -14,7 +14,7 @@ class EmailTest < ActiveSupport::TestCase teardown do @user.destroy if @user.persisted? # just in case - @other_user.destroy + @other_user.destroy if @other_user.persisted? end -- cgit v1.2.3 From 42a76e82c8c1911f04a71244eea3ac07275367df Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 18 Dec 2012 14:09:25 +0100 Subject: adopted functional tests to new controller design --- users/test/functional/users_controller_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/users/test/functional/users_controller_test.rb b/users/test/functional/users_controller_test.rb index b31a642..1fa1462 100644 --- a/users/test/functional/users_controller_test.rb +++ b/users/test/functional/users_controller_test.rb @@ -50,7 +50,7 @@ class UsersControllerTest < ActionController::TestCase user.expects(:attributes=).with(user.params) user.expects(:changed?).returns(true) user.expects(:save).returns(true) - user.expects(:reload).returns(user) + user.stubs(:email_aliases).returns([]) login user put :update, :user => user.params, :id => user.id, :format => :json @@ -65,7 +65,7 @@ class UsersControllerTest < ActionController::TestCase user.expects(:attributes=).with(user.params) user.expects(:changed?).returns(true) user.expects(:save).returns(true) - user.expects(:reload).returns(user) + user.stubs(:email_aliases).returns([]) login :is_admin? => true put :update, :user => user.params, :id => user.id, :format => :json -- cgit v1.2.3 From dc827d0a80360aa245d4d724dc42bc47571faea6 Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 18 Dec 2012 17:01:34 +0100 Subject: refactor: using tab partials for user editing --- app/views/tabs/_nav.html.haml | 2 ++ app/views/tabs/_tab.html.haml | 2 ++ app/views/tabs/_tabs.html.haml | 4 ++++ users/app/controllers/users_controller.rb | 10 ++++++++++ users/app/helpers/users_helper.rb | 4 ---- users/app/views/users/edit.html.haml | 24 +++++++++--------------- 6 files changed, 27 insertions(+), 19 deletions(-) create mode 100644 app/views/tabs/_nav.html.haml create mode 100644 app/views/tabs/_tab.html.haml create mode 100644 app/views/tabs/_tabs.html.haml diff --git a/app/views/tabs/_nav.html.haml b/app/views/tabs/_nav.html.haml new file mode 100644 index 0000000..6974c06 --- /dev/null +++ b/app/views/tabs/_nav.html.haml @@ -0,0 +1,2 @@ +%li{:class => (:active if nav == @anchor)} + %a{:href => "##{nav}", 'data-toggle' => 'tab'}= t("tabs.#{nav}") diff --git a/app/views/tabs/_tab.html.haml b/app/views/tabs/_tab.html.haml new file mode 100644 index 0000000..adab666 --- /dev/null +++ b/app/views/tabs/_tab.html.haml @@ -0,0 +1,2 @@ +.tab-pane{:id => tab, :class => (:active if tab == @anchor)} + = content_for tab diff --git a/app/views/tabs/_tabs.html.haml b/app/views/tabs/_tabs.html.haml new file mode 100644 index 0000000..8b01dbd --- /dev/null +++ b/app/views/tabs/_tabs.html.haml @@ -0,0 +1,4 @@ +%ul.nav.nav-tabs + = render :partial => '/tabs/nav', :collection => tabs +.tab-content + = render :partial => '/tabs/tab', :collection => tabs diff --git a/users/app/controllers/users_controller.rb b/users/app/controllers/users_controller.rb index 5c6767c..3d71c1a 100644 --- a/users/app/controllers/users_controller.rb +++ b/users/app/controllers/users_controller.rb @@ -3,6 +3,7 @@ class UsersController < ApplicationController skip_before_filter :verify_authenticity_token, :only => [:create] before_filter :fetch_user, :only => [:edit, :update, :destroy] + before_filter :set_anchor, :only => [:edit, :update] before_filter :authorize_admin, :only => [:index] respond_to :json, :html @@ -50,4 +51,13 @@ class UsersController < ApplicationController @user = User.find_by_param(params[:id]) access_denied unless admin? or (@user == current_user) end + + def set_anchor + @anchor = email_settings? ? :email : :account + end + + def email_settings? + params[:user] && + params[:user].keys.detect{|key| key.index('email')} + end end diff --git a/users/app/helpers/users_helper.rb b/users/app/helpers/users_helper.rb index 6d76d6f..45ca0e9 100644 --- a/users/app/helpers/users_helper.rb +++ b/users/app/helpers/users_helper.rb @@ -30,8 +30,4 @@ module UsersHelper classes.compact end - def email_settings? - params[:user] && - params[:user].keys.detect{|key| key.index('email')} - end end diff --git a/users/app/views/users/edit.html.haml b/users/app/views/users/edit.html.haml index 8fc2cab..820b80e 100644 --- a/users/app/views/users/edit.html.haml +++ b/users/app/views/users/edit.html.haml @@ -1,17 +1,11 @@ .span8.offset2 %h2=t :settings - %ul.nav.nav-tabs - %li{:class => email_settings? ? :inactive : :active} - %a{:href => '#account', 'data-toggle' => 'tab'}Account - %li{:class => email_settings? ? :active : :inactive} - %a{:href => '#email', 'data-toggle' => 'tab'}Email - - .tab-content - .tab-pane#account{:class => email_settings? ? :inactive : :active} - = user_form_with 'login_field', :legend => :change_login - = user_form_with 'password_fields', :legend => :change_password - = render 'cancel_account' if @user == current_user - .tab-pane#email{:class => email_settings? ? :active : :inactive} - = user_form_with 'email_field', :legend => :set_email_address - = user_form_with 'email_forward_field', :legend => :forward_email - = user_form_with 'email_aliases', :legend => :add_email_alias + - content_for :account do + = user_form_with 'login_field', :legend => :change_login + = user_form_with 'password_fields', :legend => :change_password + = render 'cancel_account' if @user == current_user + - content_for :email do + = user_form_with 'email_field', :legend => :set_email_address + = user_form_with 'email_forward_field', :legend => :forward_email + = user_form_with 'email_aliases', :legend => :add_email_alias + = render 'tabs/tabs', :tabs => [:account, :email] -- cgit v1.2.3