0
votes

I'm running rails 4.2.5 and I've generated all of my user creation pages through devise/twitter-bootstrap-rails/devise-bootstrap-views and then just added recaptcha through this tutorial: https://github.com/plataformatec/devise/wiki/How-To:-Use-Recaptcha-with-Devise

The sign up process works fine when clicking the recaptcha but when you put in information and don't do the recaptcha, the whole page reloads and clears and it throws an "email can't be blank" error despite having filled that in.

Any help figuring out how to fix the error handling would be appreciated.

1

1 Answers

0
votes

Assuming you have used the code from the how-to link - just try adding a few puts logs to console and see what you're getting:

class RegistrationsController < Devise::RegistrationsController
  prepend_before_action :check_captcha, only: [:create] # Change this to be any actions you want to protect.

  private
    def check_captcha
      # v---- (1) One log here
      puts "Verify recaptcha: #{verify_recaptcha}"
      unless verify_recaptcha
        # v---- (2) Another one here
        puts "Signup params: #{sign_up_params}"
        self.resource = resource_class.new sign_up_params
        resource.validate # Look for any other validation errors besides Recaptcha
        # v---- (3) And one here
        puts "Validation errors: #{resource.errors.full_messages}"
        respond_with_navigational(resource) { render :new }
      end 
    end
end

Hopefully, this will give you enough info to sort this out.

Bonus: https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html is a great source of ideas on how to debug code and find your way out by using simple puts.