From 2abfd38aee3be6fea50265d9314541a68f283d93 Mon Sep 17 00:00:00 2001 From: Stephan Kaag Date: Wed, 3 Jul 2013 22:04:22 +0200 Subject: [PATCH] Refactor code that raises deprecating warnings in Rails 4 --- app/models/topic.rb | 4 ++-- app/models/topic_user.rb | 2 +- app/services/user_blocker.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/topic.rb b/app/models/topic.rb index 72818d232db..17b07fc1564 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -89,9 +89,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