#10 Invisible Captcha
SummaryPart of a good User Experience is making your application easy to use for your users. However, a few bad apples often cause a hinderance to your UX/UI by the addition of Captchas. Learn how to create invisible captchas to protect your forms while delivering a good UX.
rails form security 4:47
In a recent version of this gem, the model helpers have since been deprecated and removed. Instead of calling the validator within your model, you can now call them in your controller on a per action basis.
For example, if you have a subject honeypot, you can add this to your controller if you are only wanting to capture it for the create action.
invisible_captcha only: :create, honeypot: :subject, on_spam: :spam_received private def spam_received redirect_to root_path end
<%= invisible_captcha %> <%= f.invisible_captcha :subtitle %>
invisible_captcha only: :send_contact, on_spam: :spam_detected private def spam_detected redirect_to root_path, alert: 'Spam detected' end
InvisibleCaptcha.setup do |config| config.sentence_for_humans = 'If you are a human, ignore this field' config.error_message = 'You are a robot!' config.honeypots += 'fake_resource_title' config.visual_honeypots = false end