Develop: Recaptcha not working

my Devise Recaptcha is not working correctly because I can skip it and still register .

I followed the Devise at wiki - https://github.com/plataformatec/devise/wiki/How-To:-Use-Recaptcha-with-Devise and got everything I accepted when I ran into the problem above.

Here is my code:

application / controllers / users / registrations.rb

class Users::RegistrationsController < Devise::RegistrationsController
    def create
        if verify_recaptcha
            super
        else
            build_resource
            clean_up_passwords(resource)
            flash[:alert] = "There was an error with the recaptcha code below. Please re-enter the code and click submit."
            render_with_scope :new
        end
    end
end

routes.rb

YourApp::Application.routes.draw do

  devise_for :users do
    root :to => "devise/registrations#new"
    get "/" => "devise/registrations#new"
    post '/' => 'registrations#new', :as => :new_user_registration 
    match '/', :to => 'devise/registrations#new'    
    .
    .
    .
    .
    .
  end

  devise_for :users, :controllers => { :registrations => "users/registrations" }

  namespace :user do
    root :to => "home#index"
  end

configurations / initializers / recaptcha.rb

Recaptcha.configure do |config|
    config.public_key  = 'mykey123456789'
    config.private_key = 'mykey13456789'
end

Perhaps this does not work, because I'm in test mode, and not on my domain name?

Help will be appreciated!

+3
source share
2 answers

environment.rb :

ENV['RECAPTCHA_PUBLIC_KEY']  = 'mykey123456789'
ENV['RECAPTCHA_PRIVATE_KEY'] = 'mykey123456789'

, .

+1

All Articles