From 5b352687fc8c8dc5f0c5b4f942447a8c51593a8e Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Sat, 1 Apr 2017 09:24:02 +0700 Subject: [PATCH] Updated README for manually adding invalid message (#47) --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 4ad7054..8534493 100644 --- a/README.md +++ b/README.md @@ -120,3 +120,19 @@ class ActionDispatch::IntegrationTest end end ``` + +### Invalid message without Devise + +When you are using this gem without Devise, you may find out that the invalid message is missing. +For this case, use the trick below to manually add your i18n invalid message. + +```rb +if verify_rucaptcha?(@user) && @user.save + do_whatever_you_want + redirect_to someplace_you_want +else + # this is the trick + @user.errors.add(:base, t('rucaptcha.invalid')) + render :new +end +```