设计:验证码不起作用
我的 Devise Recaptcha 无法正常工作,因为我可以直接跳过它并仍然注册。
我关注了 Devise wiki - https://github .com/plataformatec/devise/wiki/How-To:-Use-Recaptcha-with-Devise 并让一切正常工作,接受我遇到了上述问题。
这是我的代码:
app/controllers/users/registrations.rb
class Users::RegistrationsController < Devise::RegistrationsController
def create
if verify_recaptcha
super
else
build_resource
clean_up_passwords(resource)
flash[:alert] = "There was an error with the recaptcha code below. Please re-enter the code and click submit."
render_with_scope :new
end
end
end
routes.rb
YourApp::Application.routes.draw do
devise_for :users do
root :to => "devise/registrations#new"
get "/" => "devise/registrations#new"
post '/' => 'registrations#new', :as => :new_user_registration
match '/', :to => 'devise/registrations#new'
.
.
.
.
.
end
devise_for :users, :controllers => { :registrations => "users/registrations" }
namespace :user do
root :to => "home#index"
end
config/initializers/recaptcha.rb
Recaptcha.configure do |config|
config.public_key = 'mykey123456789'
config.private_key = 'mykey13456789'
end
它可能不会无法工作,因为我处于测试模式而不是我的域名?
帮助将不胜感激!
my Devise Recaptcha isn't working correctly because I can skip right over it and still register.
I followed the Devise wiki at - https://github.com/plataformatec/devise/wiki/How-To:-Use-Recaptcha-with-Devise and got everything working accept i encountered the problem above.
Here is my code:
app/controllers/users/registrations.rb
class Users::RegistrationsController < Devise::RegistrationsController
def create
if verify_recaptcha
super
else
build_resource
clean_up_passwords(resource)
flash[:alert] = "There was an error with the recaptcha code below. Please re-enter the code and click submit."
render_with_scope :new
end
end
end
routes.rb
YourApp::Application.routes.draw do
devise_for :users do
root :to => "devise/registrations#new"
get "/" => "devise/registrations#new"
post '/' => 'registrations#new', :as => :new_user_registration
match '/', :to => 'devise/registrations#new'
.
.
.
.
.
end
devise_for :users, :controllers => { :registrations => "users/registrations" }
namespace :user do
root :to => "home#index"
end
config/initializers/recaptcha.rb
Recaptcha.configure do |config|
config.public_key = 'mykey123456789'
config.private_key = 'mykey13456789'
end
It is possible it doesn't work because i am in test mode and not on my domain name?
Help would be appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在environment.rb中输入以下内容:
不在您的域名上可能会出现问题,具体取决于您注册密钥的方式。
In environment.rb put the following:
Not being on your domain name may be a problem depending on how you registered the keys.
这是一个没有安装 ImageMagick 或 RMagick 的问题,必须经历一些废话才能使其正常工作。
这些是我的考验和考验。磨难:
ImageMagick - “未找到 CORE_RL_magick_.dll”或如何使用 ruby 1.9.2 在 Windows 上安装 RMagick
This was an issue with not having ImageMagick or RMagick installed, had to go through the nonsense to get this working.
These were my trials & tribulations:
ImageMagick - "CORE_RL_magick_.dll not found" or how to install RMagick on windows with ruby 1.9.2