Skip to content

Commit

Permalink
feat(user profile): update the page
Browse files Browse the repository at this point in the history
  • Loading branch information
andreybakanovsky committed Aug 30, 2023
1 parent b5b8170 commit 4e51969
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 43 deletions.
7 changes: 7 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
default_form_builder BulmaFormBuilder
extend Memoist

Expand All @@ -11,4 +12,10 @@ def ps
helper_method memoize def account
Account.visible_for(current_user).find(ps.fetch(:account_id))
end

protected

def configure_permitted_parameters
devise_parameter_sanitizer.permit(:account_update, keys: [:name])
end
end
43 changes: 0 additions & 43 deletions app/views/devise/registrations/edit.html.erb

This file was deleted.

26 changes: 26 additions & 0 deletions app/views/devise/registrations/edit.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.columns.is-centered
.column.is-one-third
h2.title.is-4.has-text-centered My profile
= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f|
= render "devise/shared/error_messages", resource: resource
.field
= f.text_field :name, autofocus: true, type: "text", class: 'input', placeholder: "your name or nick name"
.field
= f.email_field :email, autocomplete: "email", placeholder: "email"
.field
= f.password_field :password, autocomplete: "new-password", placeholder: "password (leave blank if you don't want to change it)"
- if @minimum_password_length
p.help
| (#{@minimum_password_length} characters minimum)
.field
= f.password_field :password_confirmation, autocomplete: "new-password", placeholder: "password confirmation"
.field
= f.password_field :current_password, autocomplete: "current-password", placeholder: "current password"
p.help
| (we need your current password to confirm your changes)
.actions
.columns
.column.is-three-quarters
= f.submit "Update", class: "button is-primary"
.column.is-flex.is-justify-content-flex-end
= link_to 'Back', request.referer.present? && request.referer != edit_user_registration_path ? request.referer : root_path, class: 'button is-link'
1 change: 1 addition & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<div class="buttons">

<% if user_signed_in? %>
<%= link_to 'My profile', edit_user_registration_path, class: 'button is-light' %>
<%= link_to 'Log out', destroy_user_session_path, method: :delete, class: 'button is-danger' %>
<% else %>
<%= link_to 'Sign up', new_user_registration_path, class: 'button is-primary' %>
Expand Down

0 comments on commit 4e51969

Please sign in to comment.