Just got a report that we’re getting spammed by a spambot.
Then I recalled a remark @smeevil made about a technique he used to fight off spambots: create a valid form element but put it away somewhere off screen (a hidden field won’t probably work)
table.rb:
class Table < ActiveRecord::Base attr_accessor :company validates_length_of :company, :maximum => 0, :allow_nil => true, :message => "Don't spam us, OK?" end |
# new.html.erb:
<%= error_message_on :abuse, :company, {
:prepend_text => "<div class='error'>",
:append_text => "</div>",
:css_class => "flash"
} %>
<% form_for @table do |f| %>
<%= f.text_field :company, :class => "your_company"%>
<%= f.label :real_field %><br />
<%= f.text_field :real_field %>
<% end %>
<script LANGUAGE="javascript">
document.getElementById("table_real_field").focus();
</script>
# site.css
.your_company { position: absolute; top: -1000px; left: -1000px; } |