User profile page setup

This commit is contained in:
Trevor Vallender 2023-08-18 17:45:38 +01:00
parent 2560f2e4f7
commit 7fc05d6c9c
4 changed files with 17 additions and 2 deletions

View File

@ -56,6 +56,11 @@ nav {
} }
} }
main {
max-width: 100em;
margin: 0 auto;
}
a:link, a:visited { a:link, a:visited {
color: var(--highlight-color); color: var(--highlight-color);
} }

View File

@ -17,7 +17,7 @@ class UsersController < ApplicationController
end end
def show def show
@user = User.find(params[:id]) @user = User.find_by(username: params[:id])
end end
private private

View File

@ -17,4 +17,12 @@ class User < ApplicationRecord
format: { with: /\A.*@.*\..*\z/ } # Only very basic regex format: { with: /\A.*@.*\..*\z/ } # Only very basic regex
validates :password, confirmation: true validates :password, confirmation: true
def to_param
username
end
def full_name
"#{first_name} #{last_names}"
end
end end

View File

@ -1 +1,3 @@
<%= @user.username %> <h2><%= @user.username %></h2>
<h4><%= @user.full_name %></h4>