Skip to content

Commit

Permalink
work in progress on duplicate title issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanoats committed Jun 2, 2011
1 parent 49a49bb commit f254bb9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/wordpress/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,18 @@ def to_refinery
user = ::User.find_by_username(creator) || ::User.first
raise "Referenced User doesn't exist! Make sure the authors are imported first." \
unless user

post = ::BlogPost.create! :title => title, :body => content_formatted, :draft => draft?,

begin
is_draft = draft? ? "true" : false
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,
: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
Expand Down

0 comments on commit f254bb9

Please sign in to comment.