Problems with comments

Today, my good friend “Esberrito” warned me that comments were not working in the blog. I hadn’t realised earlier, but I had them enabled so they should have appeared all the time.

I investigated a bit, and it turns out that there’s some bug (apparently related to saving a post as draft, then publishing) that makes the post have an empty “permalink”. When this happens, the link to the blog post looks exactly like the view of the posts for that particular day (say, http://hcoder.org/2008/11/23/ instead of http://hcoder.org/2008/11/23/why-i-hate-rubygems), so Typo decides that it shouldn’t show the comment form.

The bad news is that many posts are fucked now (although I have fixed some of the most recent ones). The good news is that it’s more or less easy to fix. You just have to connect to a “Rails terminal” with the production configuration (with ./script/console production) and do something like this for each post you want to fix:

a = Article.find(:first, :conditions => [“title LIKE ?”, “GPG%”]) => #<Article id: 41, type: “Article”, yadda, yadda, yadda, …> a.title => “GPG confusion” a.permalink = a.stripped_title => “gpg-confusion” a.save => true

Lesson learned: don’t save as draft for now (maybe I should upgrade to 5.1.3, it seems fixed there). Instead, untick the “Online” under “Post settings”, and hit “Publish”. That will assign a default, sane permalink value.