From 13f4f6ca06a216962f4c25fa0d6041945cfb3fb5 Mon Sep 17 00:00:00 2001 From: David Gay Date: Fri, 3 Nov 2023 01:27:49 -0400 Subject: Better trainer card --- app/models/user.rb | 4 +++ app/views/layouts/application.html.erb | 2 +- app/views/users/show.html.erb | 49 +++++++++++++++++++--------------- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index ed3f425..4ad0a1e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -6,4 +6,8 @@ class User < ApplicationRecord has_many :checkpoints, through: :runs has_many :pokedex_entries, dependent: :destroy has_many :runs, dependent: :restrict_with_error + + def pokedex_captured_count + pokedex_entries.joins(:pokemon).select("distinct pokemons.pokedex_num").count + end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 0102ea6..2332cd5 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -24,7 +24,7 @@