Updated README for manually adding invalid message (#47)

This commit is contained in:
Lei Zhang 2017-04-01 09:24:02 +07:00 committed by Jason Lee
parent 18701f7ae4
commit 5b352687fc
1 changed files with 16 additions and 0 deletions

View File

@ -120,3 +120,19 @@ class ActionDispatch::IntegrationTest
end end
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
```