recaptcha
recaptcha copied to clipboard
Recaptcha::RecaptchaError in Thredded::PostsController#create
If the user don't check the reCaptcha, show this error: Recaptcha::RecaptchaError in Thredded::PostsController#create
I am using the thredded gem forum.
in my GemFile
ruby '2.4.1'
gem 'rails', '~> 5.2.0'
gem "recaptcha", require: "recaptcha/rails"
gem 'thredded'
In view
<%= recaptcha_tags %>
In controller
def create
@post_form = Thredded::PostForm.new(
user: thredded_current_user, topic: parent_topic, post_params: new_post_params
)
authorize_creating @post_form.post
if verify_recaptcha(model: @post_form) && @post_form.save
redirect_to post_path(@post_form.post, user: thredded_current_user)
else
render :new
end
end
it things it's an AR object and tries to add errors ... needs a PR to make it check errors exists