Fix account page on fresh install #684
Reference in New Issue
Block a user
Delete Branch "fix-profile-page-fresh-install"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
/settings/profileon a fresh installWhy
I did a fresh install on Render (it worked great!) and I got an error when I tried accessing the Account page.
Here is an attempt to resolve an issue I encountered after doing a fresh installation.
@@ -7,12 +7,22 @@ class User < ApplicationRecordvalidates :email, presence: true, uniqueness: truenormalizes :email, with: ->(email) { email.strip.downcase }normalizes :first_name, :last_name, with: ->(value) { value.strip.presence }By default, the columns have a
nilvalue. When the form is saved on the UI (without values), then empty strings are saved in the database.Generally, I think it's best to normalize
Stringvalues to have sanitized data (i.e.nils instead of empty strings).@@ -14,2 +16,4 @@enddef display_name[ first_name, last_name ].compact.join(" ").presence || emailThis falls back to email because is also used on the list of members, and it looks odd without some sort of identifier. I've added a screenshot below for reference.
@@ -15,2 +15,4 @@<span class="text-gray-500 text-sm"><%= Current.user.email %></span><% end %></div></div>Until at least one name is provided, there is no point rendering the email twice.
@@ -40,3 +40,3 @@<div class="flex gap-2 items-center bg-white p-4 border border-alpha-black-25 rounded-lg"><div class="mr-1 flex justify-center items-center bg-gray-50 w-8 h-8 rounded-full border border-alpha-black-25"><p class="uppercase text-xs text-gray-500"><%= Current.user.first_name.first %></p><p class="uppercase text-xs text-gray-500"><%= Current.user.initial %></p>This was causing the page crash, when
first_namewasnilon fresh install.@@ -43,3 +43,3 @@</div><p class="text-gray-900 font-medium text-sm"><%= Current.user.first_name %> <%= Current.user.last_name %></p><p class="text-gray-900 font-medium text-sm"><%= Current.user.display_name %></p><div class="rounded-md bg-gray-100 px-1.5 py-0.5">Before was like this -
This is great, thanks for the fixes and comments on this!