I launched the new version of this site at the end of January. Everything was going fine but some weeks ago I received my first comment spam. At first I only deleted it but of course the problem got worse. There are various solutions for fighting spam. The most popular one is the usage of so called Captchas. They work well but annoy most of the users. Over at Sam Ruby's weblog I learned about another solution. There is a service provider called akismet. You send the new comments to them and they will tell you whether it is spam or not. The webservice is easy to use and there is already a ruby wrapper class available. I nearly implemented akismet but in the last minute decided to try something else at first.
The bots who are responsible for the comment spam usually are not able to use javascript for posting. My comment system already uses Ajax so I decided to limit posting to Ajax requests. In other words you have to enable javascript if you want to post a comment. Lets see if this will solve the problem. The code for checking the request type is easy:
#Ajax request?
if request.xhr?
#add comment
else
#Hey javascript required
end