diff --git a/app/models/topic.rb b/app/models/topic.rb index 5ddd18d97a3..e9cb5531405 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -91,9 +91,9 @@ class Topic < ActiveRecord::Base scope :listable_topics, lambda { where('topics.archetype <> ?', [Archetype.private_message]) } - scope :by_newest, order('topics.created_at desc, topics.id desc') + scope :by_newest, -> { order('topics.created_at desc, topics.id desc') } - scope :visible, where(visible: true) + scope :visible, -> { where(visible: true) } scope :created_since, lambda { |time_ago| where('created_at > ?', time_ago) } diff --git a/app/models/topic_user.rb b/app/models/topic_user.rb index e0c33105677..185bede5350 100644 --- a/app/models/topic_user.rb +++ b/app/models/topic_user.rb @@ -3,7 +3,7 @@ class TopicUser < ActiveRecord::Base belongs_to :topic scope :starred_since, lambda { |sinceDaysAgo| where('starred_at > ?', sinceDaysAgo.days.ago) } - scope :by_date_starred, group('date(starred_at)').order('date(starred_at)') + scope :by_date_starred, -> { group('date(starred_at)').order('date(starred_at)') } scope :tracking, lambda { |topic_id| where(topic_id: topic_id) diff --git a/app/services/user_blocker.rb b/app/services/user_blocker.rb index a0c708ad2ed..355952ea9ee 100644 --- a/app/services/user_blocker.rb +++ b/app/services/user_blocker.rb @@ -23,7 +23,7 @@ class UserBlocker def hide_posts Post.where(user_id: @user.id).update_all(["hidden = true, hidden_reason_id = COALESCE(hidden_reason_id, ?)", Post.hidden_reasons[:new_user_spam_threshold_reached]]) topic_ids = Post.where('user_id = ? and post_number = ?', @user.id, 1).pluck(:topic_id) - Topic.update_all({ visible: false }, id: topic_ids) unless topic_ids.empty? + Topic.where(id: topic_ids).update_all({ visible: false }) unless topic_ids.empty? end def unblock