Created
July 24, 2016 07:40
-
-
Save AnkurVyas-BTC/37564bebb3c8bc66a3e312e6cb177711 to your computer and use it in GitHub Desktop.
Index method of the message controller.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MessagesController < ApplicationController | |
def index | |
@message = Message.all | |
#Retrives all messages and divides into two groups todays messages and other messages | |
@grouped_messages = @message.group_by{ |t| t.created_at.to_date == DateTime.now.to_date } | |
if @grouped_messages[false].present? | |
#Create month wise groups of messages | |
@month_wise_sorted_alerts = @grouped_messages[false].group_by{ |t| t.created_at.month} | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment