app/controllers/your_data_controller.rb
def update_password
    assert_params_must_have :old_password

    # Check if old password matches
    unless @current_user.password_equals?(params[:old_password])
      @current_user.errors.add(:current_password, "is typed incorrectly")
      @user = @current_user
      render :action => 'edit_password' and return
    end

    # Load instance variables
    @user                       = @current_user
    @user.password              = params[:user][:password]
    @user.password_confirmation = params[:user][:password_confirmation]

    # Try to update user information
    if @user.save
      flash[:notice] = 'Profile has been successfully updated'
      redirect_to :action => 'index'
    else
      flash[:notice] = 'Updating error'
      edit_password
      render :action => 'edit_password'
    end
  end
#
# Updates user's password.
#

Updates user's password.
Updates user ' s password .
def update_password
    assert_params_must_have :old_password
    unless @current_user.password_equals?(params[:old_password])
      @current_user.errors.add(:current_password, "is typed incorrectly")
      @user = @current_user
      render :action => 'edit_password' and return
    end
    @user                       = @current_user
    @user.password              = params[:user][:password]
    @user.password_confirmation = params[:user][:password_confirmation]
    if @user.save
      flash[:notice] = 'Profile has been successfully updated'
      redirect_to :action => 'index'
    else
      flash[:notice] = 'Updating error'
      edit_password
      render :action => 'edit_password'
    end
  end
def update_password assert_params_must_have :old_password unless @current_user . password_equals? ( params [ :old_password ] ) @current_user . errors . add ( :current_password , "is typed incorrectly" ) @user = @current_user render :action => 'edit_password' and return end @user = @current_user @user . password = params [ :user ] [ :password ] @user . password_confirmation = params [ :user ] [ :password_confirmation ] if @user . save flash [ :notice ] = 'Profile has been successfully updated' redirect_to :action => 'index' else flash [ :notice ] = 'Updating error' edit_password render :action => 'edit_password' end end
Updates user's password.
Updates user ' s password .
# Check if old password matches
 # Load instance variables
 # Try to update user information
