Skip to content

Commit ce64b6b

Browse files
committed
protect news reorganization with SQL transaction
1 parent b6497af commit ce64b6b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

app/models/news.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,12 @@ def nb_editors
260260
end
261261

262262
def reorganize(params)
263-
Paragraph.where(news_id: self.id).delete_all
264-
self.attributes = params
265-
create_parts
266-
save
263+
self.transaction do
264+
Paragraph.where(news_id: self.id).delete_all
265+
self.attributes = params
266+
create_parts
267+
save
268+
end
267269
unlock
268270
end
269271

0 commit comments

Comments
 (0)