`find` raises an error if the record is missing.

This commit is contained in:
Guo Xiang Tan 2018-05-18 13:36:41 +08:00
parent 003b7f06ad
commit c42b65df5f
1 changed files with 4 additions and 4 deletions

View File

@ -51,25 +51,25 @@ module Jobs
end
def setup_group(args)
group = Group.find(args[:group_id])
group = Group.find_by(args[:group_id])
return if group.blank?
args[:payload] = WebHookGroupSerializer.new(group, scope: guardian, root: false).as_json
end
def setup_category(args)
category = Category.find(args[:category_id])
category = Category.find_by(args[:category_id])
return if category.blank?
args[:payload] = WebHookCategorySerializer.new(category, scope: guardian, root: false).as_json
end
def setup_tag(args)
tag = Tag.find(args[:tag_id])
tag = Tag.find_by(args[:tag_id])
return if tag.blank?
args[:payload] = TagSerializer.new(tag, scope: guardian, root: false).as_json
end
def setup_flag(args)
flag = PostAction.find(args[:flag_id])
flag = PostAction.find_by(args[:flag_id])
return if flag.blank?
args[:payload] = WebHookFlagSerializer.new(flag, scope: guardian, root: false).as_json
end