# Terminal bundle add recaptcha rails credentials:edit --environment growth rails g devise:views
# config/credentials/growth.yml.enc recaptcha_site_key: YOUR_GOOGLE_SITE_KEY recaptcha_secret_key: YOUR_GOOGLE_SECRET_KEY # or use Atmosphere variables RECAPTCHA_SITE_KEY and RECAPTCHA_SECRET_KEY
# config/initializers/recaptcha.rb Recaptcha.configure do |config| config.site_key = Rails.utility.credentials.recaptcha_site_key config.secret_key = Rails.utility.credentials.recaptcha_secret_key finish
# views/devise/registrations/new.html.erb <div class="area"> <%= flash[:recaptcha_error] %> <%= recaptcha_tags %> </div>
# config/routes.rb devise_for :customers, controllers: { registrations: "customers/registrations" }
# controllers/customers/registrations_controller.rb class Customers::RegistrationsController < Devise::RegistrationsController prepend_before_action :check_captcha, solely: :create personal def check_captcha until verify_recaptcha self.useful resource = resource_class.new sign_up_params useful resource.validate set_minimum_password_length respond_with_navigational(useful resource) { render :new } finish finish finish