Imran Ahmad
Imran Ahmad

Reputation: 2927

recaptcha.rb not found in initializer

I am following this link for captcha implementation. After including gem "recaptcha", require: "recaptcha/rails" in my Gemfile when I run bundle install at last, recaptcha.rb is not getting generated. How to fix it?

Upvotes: 0

Views: 214

Answers (2)

Amit Attri
Amit Attri

Reputation: 277

You should create it manually by yourself in the config/initializers folder as recaptcha.rb. In this file you can put your keys and other modifications.

Recaptcha.configure do |config|
  config.public_key  = 'Replace with your public key'
  config.private_key = 'Replace with your private key'
end

Upvotes: 3

Rory O'Kane
Rory O'Kane

Reputation: 30428

In general, just adding a gem to your Gemfile won’t cause any files to be generated. There is no reason to expect config/initializers/recaptcha.rb to exist after the steps you have described.

Some Rails gems include new Rails generators to create configuration files. For example, Devise implements rails generate devise:install. However, I see no mention of such a generator in the README for reCAPTCHA. So if you want to have a configuration file at config/initializers/recaptcha.rb, like the example in reCAPTCHA’s README, you should just create that file yourself using your text editor, copy and paste the example contents in, and modify it for your needs. This looks like the structure for that file:

Recaptcha.configure do |config|
  # configure whatever you need to here
end

Upvotes: 1

Related Questions