1, add recaptcha gem to gemfile.
gem 'recaptcha', :require => 'recaptcha/rails'
2, the run bundle
bundle install
3, register an app in google recaptcha with following link
https://www.google.com/recaptcha/admin
4, add recaptch.rb with following code in instializers
Recaptcha.configure do |config|
config.public_key = 'xxxxxxxxxxxxxxxxxxxc' #site key
config.private_key = 'xxxxxxxxxxxxxxxy' #secreat key
config.api_version = 'v2'
end
5, add below tag in sign up form
<%= recaptha_tags %>
6, add below code in regitsration create method
def create
if verify_recaptcha
super
else
build_resource(sign_up_params)
flash.now[:alert] = 'There was an error with the recaptcha code below. Please re-enter the code.'
render :new
end
end
that's it..