Use the library . You (almost) always assign code from people who are better suited to the subdomain than you. The Akismet Wordpress guys forgot more about blog spam than I know, and for a while I was an anti-spam researcher by email. You might be interested in the Rails integration plugin for Akismet .
Protection in variety . Spam is a bizarre problem because the more popular a countermeasure becomes, the worse it gets. As such, especially for low-profile sites, you can get shockingly good results by encoding simple one-time triplets. I will not give you the code to copy / paste because it defeats the excercise goal: to have countermeasures that are globally unique.
One simple example is a hidden form element that starts as some randomized line and which is set by a known Javascript code value. Then you give up everything that does not matter well. This blocks clients who do not implement Javascript, which includes the vast majority of spam scripts. Of course, there are problems, as some legitimate clients also block Javascript - but really, if you use Rails, I assume that you think cookies are enabled and Javascript is working.
source share