Skip to content

Commit

Permalink
fix update profile (#345)
Browse files Browse the repository at this point in the history
  • Loading branch information
ka8725 authored Jun 6, 2024
1 parent d7fed6b commit ae644d9
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 13 deletions.
15 changes: 11 additions & 4 deletions app/controllers/users/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,25 @@ def create
end
end

protected
def edit_profile
authenticate_scope!
render :edit_profile
end

private

def update_resource(resource, params)
resource.update(params)
end

def devise_mapping
@devise_mapping ||= Devise.mappings[:user]
end

private

def after_sign_up_path_for(resource)
after_sign_in_url = session.delete(:after_sign_in_url)
return after_sign_in_url if after_sign_in_url.present?

super
end
end
end
10 changes: 1 addition & 9 deletions app/views/devise/registrations/edit.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,7 @@
.column.is-one-third
.field
img src=asset_path(avatar_for(current_user)) class="rounded-avatar" id='account-image'
.column
.file#file-input.is-light.is-pulled-right
label.file-label.is-light
= f.file_field :avatar, class: 'file-input'
span.file-cta
span.file-icon
i.fa.fa-camera
span.file-label
| Add photo
= link_to "Channge photo", edit_profile_path
= render "devise/shared/error_messages", resource: resource
.field
= f.text_field :name, autofocus: true, type: "text", class: 'input', placeholder: "your name or nick name"
Expand Down
24 changes: 24 additions & 0 deletions app/views/devise/registrations/edit_profile.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.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|
.columns.is-mobile
.column.is-one-third
.field
img src=asset_path(avatar_for(current_user)) class="rounded-avatar" id='account-image'
.column
.file#file-input.is-light.is-pulled-right
label.file-label.is-light
= f.file_field :avatar, class: 'file-input'
span.file-cta
span.file-icon
i.fa.fa-camera
span.file-label
| Add photo
= render "devise/shared/error_messages", resource: resource
div.buttons.is-flex.is-justify-content-flex-end
= link_to request.referer.present? && request.referer != edit_user_registration_path ? request.referer : root_path, class: 'button is-light' do
span.icon
i.fa.fa-chevron-left
|   Back
= f.submit "Update", class: "button is-primary"
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

resources :subscribers, only: %i[create]

get '/users/edit_profile', to: 'users/registrations#edit_profile', as: 'edit_profile'

resource :wizard, only: [] do
get 'new_account', on: :member
post 'create_account', on: :member
Expand Down

0 comments on commit ae644d9

Please sign in to comment.