Raise an error if create fails.

This commit is contained in:
Guo Xiang Tan 2016-06-13 12:24:38 +08:00
parent 494f1f9fae
commit 8c3e63f87a
No known key found for this signature in database
GPG Key ID: 19C321C8952B0F72
1 changed files with 2 additions and 2 deletions

View File

@ -159,7 +159,7 @@ class TopicLink < ActiveRecord::Base
next if parsed && parsed.host && parsed.host.length > TopicLink.max_domain_length
added_urls << url
TopicLink.create(post_id: post.id,
TopicLink.create!(post_id: post.id,
user_id: post.user_id,
topic_id: post.topic_id,
url: url,
@ -184,7 +184,7 @@ class TopicLink < ActiveRecord::Base
url: reflected_url)
unless tl
tl = TopicLink.create(user_id: post.user_id,
tl = TopicLink.create!(user_id: post.user_id,
topic_id: topic_id,
post_id: reflected_post.try(:id),
url: reflected_url,