Skip to content

Instantly share code, notes, and snippets.

@s01ipsist
s01ipsist / recaptcha.rb
Created August 20, 2019 10:24
GoogleRecaptcha Ruby
# https://developers.google.com/recaptcha/docs/verify
# app/controllers/application_controller.rb
def recaptcha_valid?
recaptcha_response = params['g-recaptcha-response']
return false unless recaptcha_response
GoogleRecaptcha.new.verify_recaptcha(response: recaptcha_response, remoteip: request.remote_ip)
rescue
false
end