diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-12-02 15:29:24 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-12-02 15:29:24 +0400 |
commit | 46bf3a094988327b08c88006c694f0a0a15f7da2 (patch) | |
tree | 82458b24bc2d77b1f711bc6579d39080748ab972 /app/controllers | |
parent | 2be5e6d44347dfb6374b4b2c87a953da06d6167d (diff) |
Refactored profile to resource. Added missing flash notice on successfull updated. Update username via ajax
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/profiles_controller.rb (renamed from app/controllers/profile_controller.rb) | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/app/controllers/profile_controller.rb b/app/controllers/profiles_controller.rb index 5f8b11fdded..1d1efb16f04 100644 --- a/app/controllers/profile_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -1,5 +1,6 @@ -class ProfileController < ApplicationController +class ProfilesController < ApplicationController before_filter :user + layout 'profile' def show end @@ -7,8 +8,15 @@ class ProfileController < ApplicationController def design end + def account + end + def update - @user.update_attributes(params[:user]) + if @user.update_attributes(params[:user]) + flash[:notice] = "Profile was successfully updated" + else + flash[:alert] = "Failed to update profile" + end respond_to do |format| format.html { redirect_to :back } @@ -19,7 +27,7 @@ class ProfileController < ApplicationController def token end - def password_update + def update_password params[:user].reject!{ |k, v| k != "password" && k != "password_confirmation"} if @user.update_attributes(params[:user]) @@ -31,14 +39,25 @@ class ProfileController < ApplicationController end def reset_private_token - current_user.reset_authentication_token! - redirect_to profile_account_path + if current_user.reset_authentication_token! + flash[:notice] = "Token was successfully updated" + end + + redirect_to account_profile_path end def history @events = current_user.recent_events.page(params[:page]).per(20) end + def update_username + @user.update_attributes(username: params[:user][:username]) + + respond_to do |format| + format.js + end + end + private def user |