Some problems with GUID

There were some problems with the guid for articles. Somehow, typo (or rather the validates_uniqueness_of API was telling me that the guid for my new article is NOT unique!). This seemed pretty impossible to me since it is really really hard to get a similar guid since it depends on the time the article was submitted.

In fact the code that determines the guid is found in the app/models/article.rb file which is generated by the following line
self.guid = Digest::MD5.new(self.body.to_s
+self.extended.to_s+self.title.to_s
+self.permalink.to_s+self.author.to_s
+Time.now.to_f.to_s).to_s if self.guid.blank?

And the line that validates it uniqueness is right at the end of the file:
validates_uniqueness_of :guid

Really weird. And there was nothing in the log/production.log file as well. Database also seems to be fine and after posting the article I can even verify that the article guid is indeed unique. Also there was nothing on the Typo mailing list.

Anyway, I got rid of the validates_uniqueness_of line and I was able to post new articles. We shall see how it goes for the next few days.

So far, I suspect that I must have messed up something somewhere else such that each new article is being posted twice, just before the first one gets into the database. However, I did install Typo over from scratch and still nothing.


comments powered by Disqus