diff --git a/app/controllers/debates_controller.rb b/app/controllers/debates_controller.rb index 990f6489b..cf6d14f65 100644 --- a/app/controllers/debates_controller.rb +++ b/app/controllers/debates_controller.rb @@ -11,7 +11,7 @@ class DebatesController < ApplicationController def show set_debate_votes(@debate) - @comments = @debate.root_comments.with_hidden.includes(:inappropiate_flags).recent.page(params[:page]) + @comments = @debate.root_comments.recent.page(params[:page]).for_render end def new diff --git a/app/models/comment.rb b/app/models/comment.rb index dca894b7c..db8fb35fc 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -14,7 +14,6 @@ class Comment < ActiveRecord::Base has_many :inappropiate_flags, :as => :flaggable - default_scope { includes(:user) } scope :recent, -> { order(id: :desc) } scope :sorted_for_moderation, -> { order(inappropiate_flags_count: :desc, updated_at: :desc) } @@ -22,6 +21,8 @@ class Comment < ActiveRecord::Base scope :archived, -> { where("archived_at IS NOT NULL AND hidden_at IS NULL") } scope :flagged_as_inappropiate, -> { where("inappropiate_flags_count > 0") } + scope :for_render, -> { with_hidden.includes(user: :organization) } + def self.build(commentable, user, body) new commentable: commentable, user_id: user.id, diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index 1b6f713ba..5ffff4a85 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -95,7 +95,7 @@ <% end %>