uses more rails-like syntax in scopes

This commit is contained in:
David Gil
2015-09-10 13:53:47 +02:00
parent 59a99ed874
commit 8ed434cc8b
4 changed files with 7 additions and 8 deletions

View File

@@ -22,7 +22,7 @@ class Comment < ActiveRecord::Base
scope :sort_for_moderation, -> { order(flags_count: :desc, updated_at: :desc) }
scope :pending_flag_review, -> { where(ignored_flag_at: nil, hidden_at: nil) }
scope :with_ignored_flag, -> { where("ignored_flag_at IS NOT NULL AND hidden_at IS NULL") }
scope :with_ignored_flag, -> { where(hidden_at: nil).where.not(ignored_flag_at: nil) }
scope :flagged, -> { where("flags_count > 0") }
scope :for_render, -> { with_hidden.includes(user: :organization) }