Skip to content

Commit

Permalink
Show latest hunts first
Browse files Browse the repository at this point in the history
  • Loading branch information
olliebennett committed May 25, 2024
1 parent 0dae88b commit 2a2cf4d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
2 changes: 0 additions & 2 deletions app/models/hunt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions app/models/hunt_membership.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@
class HuntMembership < ApplicationRecord
belongs_to :hunt, optional: false
belongs_to :user, optional: false

default_scope { order(:id) }
end
2 changes: 0 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions app/views/static_pages/homepage.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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| %>
<p>
<%= link_to "View '#{hunt.title}' Homes",
<p>
<% 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' %>
</p>
<% end %>
class: 'btn btn-warning m-1' %>
<% end %>
</p>
<% if current_user.hunts.size > hunts_shown %>
<p>
<%= link_to 'Switch to a different home hunt',
<%= link_to 'View all hunts',
hunts_path,
class: 'btn btn-outline-info' %>
</p>
Expand Down

0 comments on commit 2a2cf4d

Please sign in to comment.