2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-06 10:50:21 +08:00

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

View file

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