tfantina
tfantina

Reputation: 805

Rails ReCaptcha: Invalid site key reCAPTCHA

I keep getting the reCaptcha error

ERROR for site owner:
Invalid site key

I'm testing on localhost so I understand that this may cause some issues but I'm using Google's provided keys specifically for tests found here.

recaptcha.rb config

Recaptcha.configure do |config|
  config.public_key = '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'
  config.public_key = '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe'
end

reviews controller

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

Forum

  <%= raw recaptcha_tags %>
  <div class="actions">
    <%= f.submit %>
  </div>

Upvotes: 1

Views: 653

Answers (1)

Abhishek Kumar
Abhishek Kumar

Reputation: 694

You have a typo. You have written config.public_key twice. It should be config.public_key and config.private_key and it's values respectively

Upvotes: 1

Related Questions