ignore drafts and ignore duplicate titles
This commit is contained in:
parent
f254bb9216
commit
886b3d8bf9
|
@ -36,16 +36,16 @@ module Refinery
|
|||
unless user
|
||||
|
||||
begin
|
||||
is_draft = draft? ? "true" : false
|
||||
is_draft = draft? ? "true" : "false"
|
||||
if !draft?
|
||||
p "creating post " + title + " Draft status: " + is_draft
|
||||
post = ::BlogPost.create! :title => title, :body => content_formatted, :draft => draft?,
|
||||
:published_at => post_date, :created_at => post_date, :author => user,
|
||||
post = ::BlogPost.create! :title => title,
|
||||
:body => content_formatted,
|
||||
:draft => draft?,
|
||||
:published_at => post_date,
|
||||
:created_at => post_date,
|
||||
:author => user,
|
||||
:tag_list => tag_list
|
||||
rescue Exception => e
|
||||
# if it's not an activerecord validation error about duplicate title then raise e
|
||||
p e
|
||||
end
|
||||
|
||||
::BlogPost.transaction do
|
||||
categories.each do |category|
|
||||
post.categories << category.to_refinery
|
||||
|
@ -58,6 +58,14 @@ module Refinery
|
|||
end
|
||||
end
|
||||
|
||||
else
|
||||
p "Skipping draft post"
|
||||
end
|
||||
rescue Exception => e
|
||||
# TODO if it's not an activerecord validation error about duplicate title then raise e
|
||||
p e
|
||||
end
|
||||
|
||||
post
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user