Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix update profile #345

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading