ruby-on-rails Ruby on rails .slim文件中的Google ReCaptcha

pinkon5k  于 2023-08-08  发布在  Ruby
关注(0)|答案(1)|浏览(128)

我有一个.slim文件为我的注册页面,但当我试图添加recaptcha_tags到文件中,我得到一个错误recaptcha_tags未定义,任何人都可以提供一个小的示例代码,以集成recaptchabtags在.slim文件和控制器
关于问题的示例代码

r6hnlfcb

r6hnlfcb1#

我想你是错过了gem,添加这一行到Gemfile然后运行bundle install

gem "recaptcha", "~> 5.12"

字符串
然后用这些内容创建初始化器文件

Recaptcha.configure do |config|
  config.site_key  = Rails.application.credentials.dig(:google_recaptcha, :site_key)
  config.secret_key = Rails.application.credentials.dig(:google_recaptcha, :secret_key)

  # Uncomment the following line if you are using a proxy server:
  # config.proxy = 'http://myproxy.com.au:8080'

  # Uncomment the following lines if you are using the Enterprise API:
  # config.enterprise = true
  # config.enterprise_api_key = 'AIzvFyE3TU-g4K_Kozr9F1smEzZSGBVOfLKyupA'
  # config.enterprise_project_id = 'my-project'
end


把这个加到你的苗条档案里

= recaptcha_tags(noscript: false)


这个应该能用

相关问题