Adds Comment#for_render

This commit is contained in:
kikito
2015-08-26 19:41:42 +02:00
parent 9112cacde4
commit 48ef4df0c3
3 changed files with 4 additions and 3 deletions

View File

@@ -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

View File

@@ -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,

View File

@@ -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>