rewrite CommentsController#index to have everything in one call
This commit is contained in:
parent
1addae9cd9
commit
8dd0ac7c1d
2 changed files with 2 additions and 3 deletions
|
|
@ -3,8 +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 }
|
@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
|
||||||
@another_comments = Hash[@comments.map{|conference, comments| [conference, comments.group_by {|comment| comment.commentable}]}]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
.panel.well
|
.panel.well
|
||||||
%ul
|
%ul
|
||||||
- @another_comments.each do |conference, events|
|
- @comments.each do |conference, events|
|
||||||
%li= conference.title
|
%li= conference.title
|
||||||
- events.each do |event, comments|
|
- events.each do |event, comments|
|
||||||
%li= event.title
|
%li= event.title
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue