Ruby on rails 如何将recaptcha与DEVICE集成?
我正在使用Desive进行身份验证,并希望在注册表中添加验证码,我已经阅读了有关recaptcha的内容,有人能告诉我如何将两者集成吗?一个快速的google在Desive wiki上显示了一个页面-Ruby on rails 如何将recaptcha与DEVICE集成?,ruby-on-rails,ruby-on-rails-3,authentication,devise,recaptcha,Ruby On Rails,Ruby On Rails 3,Authentication,Devise,Recaptcha,我正在使用Desive进行身份验证,并希望在注册表中添加验证码,我已经阅读了有关recaptcha的内容,有人能告诉我如何将两者集成吗?一个快速的google在Desive wiki上显示了一个页面- 你看了吗?一个快速的谷歌在Desive wiki上显示了一个页面- 你看过吗 将添加到您的视图中(视图/设计/注册/新建) 创建文件(在config/initializers中)recaptcha.rb并添加以下代码: Recaptcha.configure do |config| con
你看了吗?一个快速的谷歌在Desive wiki上显示了一个页面- 你看过吗
添加到您的视图中(视图/设计/注册/新建
)config/initializers
中)recaptcha.rb并添加以下代码:
Recaptcha.configure do |config|
config.public_key = 'Your public key'
config.private_key = 'Your private key'
end
注册\u controller.rb
并添加此代码
class RegistrationsController < Devise::RegistrationsController
def create
if verify_recaptcha
super
else
build_resource(sign_up_params)
clean_up_passwords(resource)
flash.now[:alert] = "There was an error with the recaptcha code below. Please re-enter the code."
flash.delete :recaptcha_error
render :new
end
end
end
添加到您的视图中(视图/设计/注册/新建
)config/initializers
中)recaptcha.rb并添加以下代码:
Recaptcha.configure do |config|
config.public_key = 'Your public key'
config.private_key = 'Your private key'
end
注册\u controller.rb
并添加此代码
class RegistrationsController < Devise::RegistrationsController
def create
if verify_recaptcha
super
else
build_resource(sign_up_params)
clean_up_passwords(resource)
flash.now[:alert] = "There was an error with the recaptcha code below. Please re-enter the code."
flash.delete :recaptcha_error
render :new
end
end
end
它抛出了一个错误,上面写着“未指定私钥”。您是否为recaptcha获取私钥(步骤1)它抛出了一个错误,上面写着“未指定私钥”。您是否为recaptcha获取私钥(步骤1)