Add comment functionality to tracks
This commit is contained in:
parent
770a63e15c
commit
58208c73ac
19 changed files with 153 additions and 48 deletions
|
|
@ -17,12 +17,12 @@ module Admin
|
|||
|
||||
private
|
||||
|
||||
# Returning all available comments, ordered by created_at: :desc and by event.title
|
||||
# Returning all available comments, ordered by created_at: :desc
|
||||
def accessible_ordered_comments
|
||||
Comment.accessible_by(current_ability).joins('INNER JOIN events ON commentable_id = events.id').order('events.title', 'comments.created_at DESC')
|
||||
Comment.accessible_by(current_ability).order('comments.created_at DESC')
|
||||
end
|
||||
|
||||
# Grouping all comments by conference, and by event. It returns {:conference => {:event => [{comment_2}, {comment_1 }]}}
|
||||
# Grouping all comments by conference, and by commentable obj. It returns {:conference => {:commentable => [{comment_2}, {comment_1 }]}}
|
||||
def grouped_comments(remarks)
|
||||
remarks.group_by{ |comment| comment.commentable.program.conference }.map {|conference, comments| [conference, comments.group_by{|comment| comment.commentable}]}.to_h
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue