sorting comments after event title and created at in index
This commit is contained in:
parent
8dd0ac7c1d
commit
bc67cac873
2 changed files with 3 additions and 3 deletions
|
|
@ -3,7 +3,7 @@ module Admin
|
||||||
load_and_authorize_resource
|
load_and_authorize_resource
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@comments = Comment.accessible_by(current_ability).order(created_at: :desc).group_by { |comment| comment.commentable.conference }.map {|conference, comments| [conference, comments.group_by {|comment| comment.commentable}]}.to_h
|
@comments = Comment.accessible_by(current_ability).joins('INNER JOIN events ON commentable_id = events.id').order('events.title', 'comments.created_at DESC').group_by{ |comment| comment.commentable.conference }.map {|conference, comments| [conference, comments.group_by{|comment| comment.commentable}]}.to_h
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
.panel.well
|
.panel.well
|
||||||
%ul
|
%ul
|
||||||
- @comments.each do |conference, events|
|
- @comments.each do |conference, events|
|
||||||
%li= conference.title
|
%i.li= conference.title
|
||||||
- events.each do |event, comments|
|
- events.each do |event, comments|
|
||||||
%li= event.title
|
%b.li= event.title
|
||||||
- comments.each do |comment|
|
- comments.each do |comment|
|
||||||
%li= comment.body
|
%li= comment.body
|
||||||
%li= comment.user.name
|
%li= comment.user.name
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue