Post#copy_notes_to: wrap in transaction.

This commit is contained in:
evazion
2018-03-31 11:44:49 -05:00
parent 04ecca6a06
commit 8e7ad9eb97

View File

@@ -1415,6 +1415,7 @@ class Post < ApplicationRecord
end end
def copy_notes_to(other_post) def copy_notes_to(other_post)
transaction do
if id == other_post.id if id == other_post.id
errors.add :base, "Source and destination posts are the same" errors.add :base, "Source and destination posts are the same"
return false return false
@@ -1440,6 +1441,7 @@ class Post < ApplicationRecord
dummy.save dummy.save
end end
end end
end
module ApiMethods module ApiMethods
def hidden_attributes def hidden_attributes