From f254bb921688400c2ad123fee8c07be82b515c02 Mon Sep 17 00:00:00 2001 From: Ivan Storck Date: Thu, 2 Jun 2011 14:26:18 -0700 Subject: [PATCH] work in progress on duplicate title issue --- lib/wordpress/post.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/wordpress/post.rb b/lib/wordpress/post.rb index 51d5bef..f239020 100644 --- a/lib/wordpress/post.rb +++ b/lib/wordpress/post.rb @@ -34,11 +34,18 @@ module 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