Ruby on rails rails中的reCaptcha
我已经从安装了recaptcha gem,并且添加了Ruby on rails rails中的reCaptcha,ruby-on-rails,recaptcha,Ruby On Rails,Recaptcha,我已经从安装了recaptcha gem,并且添加了 <%= recaptcha_tags > 我的控制器是这样的 def create if verify_recaptcha super else build_resource clean_up_passwords(resource) flash.now[:alert] = "There was an error with the recaptcha code below. Please r
<%= recaptcha_tags >
我的控制器是这样的
def create
if verify_recaptcha
super
else
build_resource
clean_up_passwords(resource)
flash.now[:alert] = "There was an error with the recaptcha code below. Please re-enter the code."
render_with_scope :new
end
end
我也遵循了下面的链接,因为我在注册控制器中也使用了它,但每次验证recaptcha返回false时,根据代码判断,如果您想使用环境变量方式配置recaptcha,必须在加载recaptcha之前设置这些环境变量 因为在初始化器运行之前绑定器需要gem,所以在初始化器中设置这些环境变量太晚了 为什么不使用
Recaptcha.configure do |config|
config.public_key = ...
...
end
方法?我成功地将您的代码作为起点,并进行了以下更改:
<%= recaptcha_tags >
<%= recaptcha_tags >
<%= recaptcha_tags %>
def create
if verify_recaptcha
super
else
flash.delete(:recaptcha_error)
flash.now[:alert] = "There was an error with the recaptcha code below. Please re-enter the code."
render :new
end
end