Skip to content

Commit 2a2cf4d

Browse files
committed
Show latest hunts first
1 parent 0dae88b commit 2a2cf4d

File tree

4 files changed

+8
-14
lines changed

4 files changed

+8
-14
lines changed

app/models/hunt.rb

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ class Hunt < ApplicationRecord
99

1010
validates :title, presence: true
1111

12-
default_scope { order(:id) }
13-
1412
auto_strip_attributes :title, squish: true
1513

1614
def token_match?(test_token)

app/models/hunt_membership.rb

-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@
33
class HuntMembership < ApplicationRecord
44
belongs_to :hunt, optional: false
55
belongs_to :user, optional: false
6-
7-
default_scope { order(:id) }
86
end

app/models/user.rb

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ class User < ApplicationRecord
1111
has_many :hunts, through: :hunt_memberships
1212
has_many :ratings, dependent: :destroy
1313

14-
default_scope { order(:id) }
15-
1614
def display_name
1715
email.scan(/.+@/).last[0...-1]
1816
end

app/views/static_pages/homepage.html.erb

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
<%= render 'layouts/about_blurb' %>
44

5-
<% hunts_shown = 2 %>
5+
<% hunts_shown = 5 %>
66

77
<% if user_signed_in? %>
8-
<% current_user.hunts.order(updated_at: :desc).limit(hunts_shown).each do |hunt| %>
9-
<p>
10-
<%= link_to "View '#{hunt.title}' Homes",
8+
<p>
9+
<% current_user.hunts.order(created_at: :desc).limit(hunts_shown).each do |hunt| %>
10+
<%= link_to hunt.title,
1111
hunt_homes_path(hunt),
12-
class: 'btn btn-warning' %>
13-
</p>
14-
<% end %>
12+
class: 'btn btn-warning m-1' %>
13+
<% end %>
14+
</p>
1515
<% if current_user.hunts.size > hunts_shown %>
1616
<p>
17-
<%= link_to 'Switch to a different home hunt',
17+
<%= link_to 'View all hunts',
1818
hunts_path,
1919
class: 'btn btn-outline-info' %>
2020
</p>

0 commit comments

Comments
 (0)