Merge pull request #1140 from stephankaag/code_refactoring
Refactor code that raises deprecating warnings in Rails 4
This commit is contained in:
commit
f9d1fcb169
|
@ -91,9 +91,9 @@ class Topic < ActiveRecord::Base
|
||||||
|
|
||||||
scope :listable_topics, lambda { where('topics.archetype <> ?', [Archetype.private_message]) }
|
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) }
|
scope :created_since, lambda { |time_ago| where('created_at > ?', time_ago) }
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ class TopicUser < ActiveRecord::Base
|
||||||
belongs_to :topic
|
belongs_to :topic
|
||||||
|
|
||||||
scope :starred_since, lambda { |sinceDaysAgo| where('starred_at > ?', sinceDaysAgo.days.ago) }
|
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|
|
scope :tracking, lambda { |topic_id|
|
||||||
where(topic_id: topic_id)
|
where(topic_id: topic_id)
|
||||||
|
|
|
@ -23,7 +23,7 @@ class UserBlocker
|
||||||
def hide_posts
|
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]])
|
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_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
|
end
|
||||||
|
|
||||||
def unblock
|
def unblock
|
||||||
|
|
Loading…
Reference in New Issue