Skip to content

Commit a2c4e68

Browse files
committed
on validation error for a news reorganization rollback transaction
The rollback is needed as the new_version is created only on successful save. Without rollback, the news content is updated without new version created.
1 parent ce64b6b commit a2c4e68

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

app/models/news.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ def reorganize(params)
264264
Paragraph.where(news_id: self.id).delete_all
265265
self.attributes = params
266266
create_parts
267-
save
267+
# Let commit transaction only if save is successful so version will be well created
268+
raise ActiveRecord::Rollback unless save
268269
end
269270
unlock
270271
end

0 commit comments

Comments
 (0)