ambethia / recaptcha

ReCaptcha helpers for ruby apps

Home Page:http://github.com/ambethia/recaptcha

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

recaptcha succeeds on view but verify_recaptcha fails in ruby

majuabir opened this issue · comments

My recaptcha widget is works just fine in my frontend. I click it and I get the green checkmark, but invoking verify_recaptcha in my ruby code always returns false for some reason. I took the route of initializing my keys in config/initializers/recaptcha.rb

Recaptcha.configure do |config|
  config.site_key  = 'x'
  config.secret_key = 'y'
end

My test for the veryify_recaptcha goes like this

def captcha_test
    valid = false
    if verify_recaptcha == true
      valid = true
    end
    return valid
  end

I know this looks so redundant but I'm referencing a solution here #219 where jonathanrbowman would make a variable to hold the return of verify_recaptcha which seemed to work for him.

Are there any common mistakes I should consider?

Got it figured out. <%=recaptcha_tags=> must be included in a form for it to work.

Got it figured out. <%=recaptcha_tags=> must be included in a form for it to work.

Thank you! I'd been scratching my head for ages trying to figure out why it wasn't working. You are 100% correct and as soon as I moved <%=recaptcha_tags=> into the form it worked perfectly!