rails 4 deprecation fixes

This commit is contained in:
Sam 2013-10-24 13:02:25 +11:00
parent 6fac09aeaa
commit ff957a7b37
3 changed files with 3 additions and 5 deletions

View File

@ -14,7 +14,7 @@ class ActiveRecord::Base
# note: update_attributes still spins up a transaction this can cause contention
# this method performs the raw update sidestepping the locking
def update_columns(hash)
self.class.update_all(hash, self.class.primary_key => self.id)
self.class.where(self.class.primary_key => self.id).update_all(hash)
end
def exec_sql(*args)

View File

@ -112,9 +112,9 @@ class PostCreator
def track_latest_on_category
if @post && @post.errors.count == 0 && @topic && @topic.category_id
Category.update_all( {latest_post_id: @post.id}, {id: @topic.category_id} )
Category.where(id: @topic.category_id).update_all(latest_post_id: @post.id)
if @post.post_number == 1
Category.update_all( {latest_topic_id: @topic.id}, {id: @topic.category_id} )
Category.where(id: @topic.category_id).update_all(latest_topic_id: @topic.id)
end
end
end

View File

@ -70,10 +70,8 @@ module DiscourseTask
topic.update_meta_data(complete: false)
topic.add_moderator_post(current_user, I18n.t(:'task.reversed'))
end
end
render nothing: true
end