Skip to content

Commit

Permalink
added an invisible captcha to prevent spam
Browse files Browse the repository at this point in the history
  • Loading branch information
towanda committed Oct 5, 2011
1 parent 6d06f5f commit aeef193
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Expand Up @@ -9,3 +9,8 @@ config/deploy.rb
#eclipse
.project
.settings

.rvmrc

#rubymine
.idea
13 changes: 12 additions & 1 deletion app/controllers/users_controller.rb
@@ -1,7 +1,8 @@
class UsersController < ApplicationController
before_filter :require_no_user, :only => [:new, :create]
before_filter :require_user, :only => [:show, :profile, :edit, :update]

before_filter :form_span_control, :only => :create

def new
@user = User.new
end
Expand Down Expand Up @@ -38,4 +39,14 @@ def update
render :action => :edit
end
end

private

def form_span_control
unless params['ruby_creator'] == 'Yukihiro Matsumoto'
render :text => "Please make sure cookies and js are enabled"
return false
end
end

end
6 changes: 5 additions & 1 deletion public/javascripts/application.js
Expand Up @@ -2,4 +2,8 @@
// This file is automatically included by javascript_include_tag :defaults
$(function() {
$("#datetime").datetimepicker({showOn: 'button', buttonImage: '/images/calendar.gif', buttonImageOnly: true });
});
});

$(document).ready( function(){
$('#new_user').append( '<input type="hidden" id="ruby_creator" name="ruby_creator" value="Yukihiro Matsumoto">');
})

0 comments on commit aeef193

Please sign in to comment.