Skip to content

Commit a134b68

Browse files
committed
Add avatar field to change avatar and add default avatar
1 parent d00a326 commit a134b68

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

app/views/devise/registrations/edit.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
hint: "we need your current password to confirm your changes",
2323
required: true,
2424
input_html: { autocomplete: "current-password" } %>
25-
<%= f.input :photo
25+
<%= f.input :photo, label: "Photo url"
2626

2727
%>
2828
</div>
2929

3030
<div class="form-actions">
31-
<%= f.button :submit, "Update", class: "btn-primary" %>
31+
<%= f.button :submit, "Update", class: "btn-primary mt-2" %>
3232
</div>
3333
<% end %>
3434

app/views/shared/_navbar.html.erb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
<% if user_signed_in? %>
2121
<span class="avatar-content">
2222
<figure class="figure-image" data-action="click->avatar-dropdown#action">
23-
<%= image_tag "default-avatar", crop: :fill, class: 'avatar-bordered', alt: 'avatar' %>
23+
<% if current_user.photo == "" %>
24+
<%= image_tag "default-avatar", crop: :fill, class: 'avatar-bordered', alt: 'avatar' %>
25+
<% else %>
26+
<%= image_tag current_user.photo, crop: :fill, class: 'avatar-bordered', alt: 'avatar' %>
27+
<% end %>
2428
</figure>
2529
<div class="dropdownmenu d-none" data-avatar-dropdown-target='dropdown'>
2630
<%= link_to "Settings", edit_user_registration_path, class: "dropdownitem" %>

0 commit comments

Comments
 (0)