summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/users_controller.rb5
-rw-r--r--app/views/home/index.html.erb2
-rw-r--r--app/views/layouts/application.html.erb2
-rw-r--r--app/views/runs/index.html.erb2
-rw-r--r--app/views/runs/show.html.erb2
-rw-r--r--app/views/users/edit.html.erb21
-rw-r--r--app/views/users/show.html.erb6
7 files changed, 32 insertions, 8 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index f411ace..20ae049 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -7,9 +7,8 @@ class UsersController < ApplicationController
def edit; end
def update
- @user.set(user_params)
- if @user.save
- redirect_to run_path(@run), notice: "Saved profile."
+ if @user.update(user_params)
+ redirect_to user_path(@user), notice: "Saved trainer card."
else
render :edit, status: :unprocessable_entity
end
diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb
index 0d693f1..457200c 100644
--- a/app/views/home/index.html.erb
+++ b/app/views/home/index.html.erb
@@ -7,7 +7,7 @@
<ul class="list-disc">
<% @latest_checkpoints.each do |checkpoint| %>
<li>At <%= checkpoint.created_at %>
- <%= checkpoint.user.email %> checked in a save for
+ <%= checkpoint.user.name %> checked in a save for
<%= link_to checkpoint.run.title, run_path(checkpoint.run) %> (<%= checkpoint.run.game.title %>)
<%= link_to "[save file]", rails_blob_path(checkpoint.save_file, disposition: "attachment") %></li>
<% end %>
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index a7ac625..12b7e6b 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -23,7 +23,7 @@
</div>
<div class="space-x-8 nav-links">
<% if user_signed_in? %>
- <%= link_to "Profile", user_path(current_user) %>
+ <%= link_to "Trainer card", user_path(current_user) %>
<%= link_to "Sign out", destroy_user_session_path %>
<% else %>
<%= link_to "Sign in", new_user_session_path %>
diff --git a/app/views/runs/index.html.erb b/app/views/runs/index.html.erb
index 97267ae..3b152c7 100644
--- a/app/views/runs/index.html.erb
+++ b/app/views/runs/index.html.erb
@@ -13,7 +13,7 @@
<ul class="list-disc">
<% @runs.each do |run| %>
- <li><%= run.game.title %> - <%= link_to run.title, run_path(run) %> - Started by <%= run.user.email %></li>
+ <li><%= run.game.title %> - <%= link_to run.title, run_path(run) %> - Started by <%= run.user.name %></li>
<% end %>
</ul>
</div>
diff --git a/app/views/runs/show.html.erb b/app/views/runs/show.html.erb
index 11fdd12..eb580ad 100644
--- a/app/views/runs/show.html.erb
+++ b/app/views/runs/show.html.erb
@@ -1,7 +1,7 @@
<h1 class="text-2xl"><%= @run.title %></h1>
<p class="subtitle"><%= @run.game.title %></p>
-<p>Run started by: <%= @run.user.email %></p>
+<p>Run started by: <%= @run.user.name %></p>
<%= link_to "New checkpoint", new_run_checkpoint_path(@run) %>
diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb
new file mode 100644
index 0000000..b0ea8a1
--- /dev/null
+++ b/app/views/users/edit.html.erb
@@ -0,0 +1,21 @@
+<%= form_with model: @user do |f| %>
+ <div>
+ <%= f.label :name, "Name" %>
+ <%= f.text_field :name %>
+ </div>
+
+ <div>
+ <%= f.submit "Save trainer card", class: "btn-primary" %>
+ </div>
+
+ <% if @user.errors.any? %>
+ <div>
+ <p><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</p>
+ <ul>
+ <% @user.errors.full_messages.each do |message| %>
+ <li><%= message %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+<% end %>
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb
index ad6675a..34308b1 100644
--- a/app/views/users/show.html.erb
+++ b/app/views/users/show.html.erb
@@ -1,10 +1,14 @@
<div class="space-y-4">
<h1 class="text-2xl">
- <span class="px-4 py-2 text-lg text-slate-900 bg-orange-600 rounded">TRAINER CARD</span>
+ <span class="px-4 py-2 text-lg text-slate-900 bg-orange-500 rounded">TRAINER CARD</span>
<%= @user.name || "Unknown" %>
</h1>
<p class="subtitle">ID No. <%= @user.id %></p>
+ <% if @user == current_user %>
+ <%= link_to "Edit trainer card", edit_user_url(@user) %>
+ <% end %>
+
<ul>
<li>Pokédex 0</li>
</ul>