Fix uniq deprecation warning

DEPRECATION WARNING: uniq is deprecated and will be removed from Rails
5.1 (use distinct instead) (called from block in <class:User> at
/home/travis/build/consul/consul/app/models/user.rb:67)
This commit is contained in:
rgarcia
2018-04-08 14:53:14 +02:00
committed by Julian Herrero
parent 4c5d58448e
commit c979cc7411

View File

@@ -64,7 +64,7 @@ class User < ActiveRecord::Base
scope :active, -> { where(erased_at: nil) } scope :active, -> { where(erased_at: nil) }
scope :erased, -> { where.not(erased_at: nil) } scope :erased, -> { where.not(erased_at: nil) }
scope :public_for_api, -> { all } scope :public_for_api, -> { all }
scope :by_comments, ->(query, topics_ids) { joins(:comments).where(query, topics_ids).uniq } scope :by_comments, ->(query, topics_ids) { joins(:comments).where(query, topics_ids).distinct }
scope :by_authors, ->(author_ids) { where("users.id IN (?)", author_ids) } scope :by_authors, ->(author_ids) { where("users.id IN (?)", author_ids) }
scope :by_username_email_or_document_number, ->(search_string) do scope :by_username_email_or_document_number, ->(search_string) do
string = "%#{search_string}%" string = "%#{search_string}%"