Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I correctly install ambethia/recaptcha with rails 3

I have done the following steps:

Added to gemfile:

gem "recaptcha"

Added to config/initializers/recaptcha.rb

Recaptcha.configure do |config|
  config.public_key  = 'MyKeyHere'
  config.private_key = 'MyKeyHere'
end

Added to view:

= raw recaptcha_tags

Ran: bundle install

...then restarted server. The result?

undefined local variable or method `recaptcha_tags' for #<#<Class:0x1053baaa0>:0x1053b69c8>
like image 989
TLK Avatar asked Dec 24 '10 21:12

TLK


2 Answers

The gem's README says to, in Rails 2 (yes, I know you're in 3—just a minute :D), include the following line to require the gem:

config.gem "recaptcha", :lib => "recaptcha/rails"

The important bit to note here is the instruction that Rails should essentially end up running require 'recaptcha/rails'. Your current Gemfile doesn't have that specified, so it may very well only be loading in the gem's core classes, not the Rails-specific tie-ins.

Try:

gem 'recaptcha', :require => 'recaptcha/rails'
like image 170
Matchu Avatar answered Nov 15 '22 18:11

Matchu


Add the following gem into your gemfile.

gem 'recaptcha', :require => 'recaptcha/rails'
like image 23
Ramiz Raja Avatar answered Nov 15 '22 20:11

Ramiz Raja