3
votes

my Devise Recaptcha isn't working correctly because I can skip right over it and still register.

I followed the Devise wiki at - https://github.com/plataformatec/devise/wiki/How-To:-Use-Recaptcha-with-Devise and got everything working accept i encountered the problem above.

Here is my code:

app/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

config/initializers/recaptcha.rb

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

It is possible it doesn't work because i am in test mode and not on my domain name?

Help would be appreciated!

2

2 Answers

1
votes

In environment.rb put the following:

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

Not being on your domain name may be a problem depending on how you registered the keys.

0
votes

This was an issue with not having ImageMagick or RMagick installed, had to go through the nonsense to get this working.

These were my trials & tribulations:

ImageMagick - "CORE_RL_magick_.dll not found" or how to install RMagick on windows with ruby 1.9.2