Skip to content

Commit 58df187

Browse files
committed
Use AR's symbol syntax for ordering relations
1 parent fb9ed32 commit 58df187

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

app/models/event.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ class Event < ApplicationRecord
2222
default_scope -> { where(label: Whitelabel[:label_id]) }
2323

2424
scope :with_topics, -> { joins(:topics).distinct }
25-
scope :current, -> { where('date >= ?', Date.today.to_time).limit(1).order('date ASC') }
26-
scope :latest, -> { where('date < ?', Date.today.to_time).order('date DESC') }
25+
scope :current, -> { where('date >= ?', Date.today.to_time).limit(1).order(date: :asc) }
26+
scope :latest, -> { where('date < ?', Date.today.to_time).order(date: :desc) }
2727
scope :unpublished, -> { where('published IS NULL') }
28-
scope :ordered, -> { order('date DESC') }
28+
scope :ordered, -> { order(date: :desc) }
2929

3030
def end_date
3131
date + 2.hours

app/models/highlight.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class Highlight < ApplicationRecord
55

66
default_scope -> { where(label: Whitelabel[:label_id]) }
77

8-
scope :active, -> { where('end_at > ?', Time.now).order('start_at').limit(1) }
8+
scope :active, -> { where('end_at > ?', Time.now).order(start_at: :asc).limit(1) }
99

1010
def disabled?
1111
end_at <= Time.now

0 commit comments

Comments
 (0)