1
私は、ローカルホスト上でテストしていRailsのreCAPTCHAの:無効なサイトキーreCAPTCHAの
ERROR for site owner:
Invalid site key
reCAPTCHAのエラーを取得しておくので、私は、これはいくつかの問題を引き起こす可能性があることを理解しますが、私はのために特別にをGoogleの提供するキーを使用していますテストfound here。
recaptcha.rbコンフィグ
Recaptcha.configure do |config|
config.public_key = '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'
config.public_key = '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe'
end
レビューコントローラ
def create
@review = Review.create(review_params)
@review.professor_id = @professor.id
@review.guest = :guest
respond_to do |format|
if verify_recaptcha(model: @review) && @review.save
format.html{ redirect_to @professor, notice: 'Review was successfully created.' }
format.json { render :show, status: :created, location: @review }
else
format.html { render :new, notice: 'Please fill out the captcha.'}
format.json { render json: @review.errors, status: :unprocessable_entity}
end
end
end
フォーラム
<%= raw recaptcha_tags %>
<div class="actions">
<%= f.submit %>
</div>
です。ありがとうございます。 – tfantina