Adds Comment#for_render
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
<% end %>
|
||||
|
||||
<div class="comment-children">
|
||||
<%= render comment.children.with_hidden.reorder('id DESC, lft') %>
|
||||
<%= render comment.children.for_render.reorder('id DESC, lft') %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user