Skip to content

Commit 94deb3e

Browse files
committed
Add name of creator to show page
1 parent 23f8101 commit 94deb3e

File tree

7 files changed

+21
-8
lines changed

7 files changed

+21
-8
lines changed

app/controllers/application_controller.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ class ApplicationController < ActionController::Base
33

44
def configure_permitted_parameters
55
# For additional fields in app/views/devise/registrations/new.html.erb
6-
devise_parameter_sanitizer.permit(:sign_up, keys: [:photo])
6+
devise_parameter_sanitizer.permit(:sign_up, keys: [:photo, :nickname])
77

88
# For additional in app/views/devise/registrations/edit.html.erb
9-
devise_parameter_sanitizer.permit(:account_update, keys: [:photo])
9+
devise_parameter_sanitizer.permit(:account_update, keys: [:photo, :nickname])
1010
end
1111
end
12+

app/controllers/lists_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ def index
99
end
1010

1111
def show
12+
@user = User.where(id: current_user.id)
1213
end
1314

1415
def new

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
<%= f.error_notification %>
66

77
<div class="form-inputs">
8+
<%= f.input :nickname,
9+
required: true %>
810
<%= f.input :email, required: true, autofocus: true %>
911

1012
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
@@ -22,9 +24,7 @@
2224
hint: "we need your current password to confirm your changes",
2325
required: true,
2426
input_html: { autocomplete: "current-password" } %>
25-
<%= f.input :photo, label: "Photo url"
26-
27-
%>
27+
<%= f.input :photo, label: "Photo url" %>
2828
</div>
2929

3030
<div class="form-actions">

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
<%= f.error_notification %>
66

77
<div class="form-inputs">
8+
<%= f.input :nickname,
9+
required: true %>
810
<%= f.input :email,
911
required: true,
10-
autofocus: true,
1112
input_html: { autocomplete: "email" }%>
1213
<%= f.input :password,
1314
required: true,

app/views/lists/show.html.erb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<div class="mb-5">
22
<img class="cloudbannerimage" src="<%= cl_image_path @list.photo.key %>" alt="Card image">
3-
<h2 class="newList text-image"> <%= @list.name %> </h2>
3+
<div class="text-image">
4+
<h2 class=""> <%= @list.name %> </h2>
5+
<% list_user = User.find_by(id: @list.user) %>
6+
<h3 class=""> By <%= list_user.nickname.capitalize %></h3>
7+
</div>
48
</div>
59

610
<div class="container">
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddNicknameToUsers < ActiveRecord::Migration[6.1]
2+
def change
3+
add_column :users, :nickname, :string
4+
end
5+
end

db/schema.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema.define(version: 2022_05_26_073949) do
13+
ActiveRecord::Schema.define(version: 2022_05_27_080540) do
1414

1515
# These are extensions that must be enabled in order to support this database
1616
enable_extension "plpgsql"
@@ -78,6 +78,7 @@
7878
t.datetime "created_at", precision: 6, null: false
7979
t.datetime "updated_at", precision: 6, null: false
8080
t.string "photo"
81+
t.string "nickname"
8182
t.index ["email"], name: "index_users_on_email", unique: true
8283
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
8384
end

0 commit comments

Comments
 (0)