2009-08-27 13:19:22 UTC
Simple SPAM protection in Rails
This for me the most simple and best working way to stop SPAM with Rails.
# originally : http://gist.github.com/167152
class Post < ActiveRecord::Base
attr_accessor :comment # fake attribute used for spam trapping
validates_length_of :comment, :in => 0..1
end
<% form_for @comment do |f| %>
...
<p style="width: 1px; height: 1px; overflow: hidden;">
Lämna följande fält tomt:
<%= f.text_area :comment %>
</p>
<% end %>
Logga in för att kommentera
