Sha256: 54412986777dbe64540d23d2e6f5ee33edcadbffd6e83d7e02ce201c4883a083

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

class ProfileController < ApplicationController
  def edit
    @update_profile_information_form = UpdateProfileInformationForm.new(name: Current.user.name, email: Current.user.email)
    @update_password_form = UpdatePasswordForm.new
    @delete_user_form = DeleteUserForm.new

    render 'profile/edit'
  end

  def update
    @update_profile_information_form = UpdateProfileInformationForm.new params.permit(:name, :email)

    return render partial: 'profile/partials/update_profile_information_form', status: :unprocessable_entity if @update_profile_information_form.invalid?

    Current.user.update(name: @update_profile_information_form.name, email: @update_profile_information_form.email)

    redirect_to profile_edit_path, flash: { status: 'profile-updated' }
  end

  def destroy
    @delete_user_form = DeleteUserForm.new params.permit(:password)

    return render partial: 'profile/partials/delete_user_form', status: :unprocessable_entity if @delete_user_form.invalid?

    user = Current.user

    logout

    user.delete

    redirect_to '/'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kaze-0.5.0 stubs/hotwire/app/controllers/profile_controller.rb