Module: Sage::ApplicationHelper

Includes:
Pagy::Frontend
Defined in:
app/helpers/sage/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#format_message_date(date) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/helpers/sage/application_helper.rb', line 15

def format_message_date(date)
  case date
  when Date.current
    "Today"
  when Date.current - 1
    "Yesterday"
  else
    if date.year == Date.current.year
      date.strftime("%B %d")
    else
      date.strftime("%B %d, %Y")
    end
  end
end

#messages_grouped_by_day(messages) ⇒ Object



10
11
12
13
# File 'app/helpers/sage/application_helper.rb', line 10

def messages_grouped_by_day(messages)
  messages.group_by { |message| message.created_at.to_date }
         .sort_by { |date, _| date }
end

#sageObject

Provide access to Sage engine routes



6
7
8
# File 'app/helpers/sage/application_helper.rb', line 6

def sage
  Sage::Engine.routes.url_helpers
end