Merge pull request #1140 from stephankaag/code_refactoring

Refactor code that raises deprecating warnings in Rails 4
This commit is contained in:
Robin Ward 2013-07-09 06:48:48 -07:00
commit f9d1fcb169
3 changed files with 4 additions and 4 deletions

View File

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

View File

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

View File

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