From 2a2cf4da76a651a13a3a00140d928fe11dcf210c Mon Sep 17 00:00:00 2001 From: Ollie Bennett Date: Sat, 25 May 2024 06:31:39 +0100 Subject: [PATCH] Show latest hunts first --- app/models/hunt.rb | 2 -- app/models/hunt_membership.rb | 2 -- app/models/user.rb | 2 -- app/views/static_pages/homepage.html.erb | 16 ++++++++-------- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/app/models/hunt.rb b/app/models/hunt.rb index 25949d22..67c45bf4 100644 --- a/app/models/hunt.rb +++ b/app/models/hunt.rb @@ -9,8 +9,6 @@ class Hunt < ApplicationRecord validates :title, presence: true - default_scope { order(:id) } - auto_strip_attributes :title, squish: true def token_match?(test_token) diff --git a/app/models/hunt_membership.rb b/app/models/hunt_membership.rb index 1be09668..f2e9b36a 100644 --- a/app/models/hunt_membership.rb +++ b/app/models/hunt_membership.rb @@ -3,6 +3,4 @@ class HuntMembership < ApplicationRecord belongs_to :hunt, optional: false belongs_to :user, optional: false - - default_scope { order(:id) } end diff --git a/app/models/user.rb b/app/models/user.rb index 8a06cfc9..8621086e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -11,8 +11,6 @@ class User < ApplicationRecord has_many :hunts, through: :hunt_memberships has_many :ratings, dependent: :destroy - default_scope { order(:id) } - def display_name email.scan(/.+@/).last[0...-1] end diff --git a/app/views/static_pages/homepage.html.erb b/app/views/static_pages/homepage.html.erb index e4a7fc91..ce84fb7a 100644 --- a/app/views/static_pages/homepage.html.erb +++ b/app/views/static_pages/homepage.html.erb @@ -2,19 +2,19 @@ <%= render 'layouts/about_blurb' %> -<% hunts_shown = 2 %> +<% hunts_shown = 5 %> <% if user_signed_in? %> - <% current_user.hunts.order(updated_at: :desc).limit(hunts_shown).each do |hunt| %> -

- <%= link_to "View '#{hunt.title}' Homes", +

+ <% current_user.hunts.order(created_at: :desc).limit(hunts_shown).each do |hunt| %> + <%= link_to hunt.title, hunt_homes_path(hunt), - class: 'btn btn-warning' %> -

- <% end %> + class: 'btn btn-warning m-1' %> + <% end %> +

<% if current_user.hunts.size > hunts_shown %>

- <%= link_to 'Switch to a different home hunt', + <%= link_to 'View all hunts', hunts_path, class: 'btn btn-outline-info' %>