Ruby on rails 3 使用现有的Desive gem和rubymine 3.1安装recaptcha gem

Ruby on rails 3 使用现有的Desive gem和rubymine 3.1安装recaptcha gem,ruby-on-rails-3,Ruby On Rails 3,我已经试过了:我试着在github上阅读文档,并让它在Rubymine上运行,我设法把自己弄糊涂了,控制器需要什么,配置文件夹需要什么。我试过谷歌,找到了一些不错的教程,但它们缺少的步骤我不一定知道该怎么跳 我想弄明白的是:我希望能够在登录注册中使用recaptcha。我已经为我的Desive登录生成了页面 到目前为止,我所拥有的: 我已经安装并附加了:Desive 1.2.rc和recaptcha 0.3.1我正在windows xp上运行Rubymine。Ruby SDK 1.8.7-p30

我已经试过了:我试着在github上阅读文档,并让它在Rubymine上运行,我设法把自己弄糊涂了,控制器需要什么,配置文件夹需要什么。我试过谷歌,找到了一些不错的教程,但它们缺少的步骤我不一定知道该怎么跳

我想弄明白的是:我希望能够在登录注册中使用recaptcha。我已经为我的Desive登录生成了页面

到目前为止,我所拥有的:

我已经安装并附加了:Desive 1.2.rc和recaptcha 0.3.1我正在windows xp上运行Rubymine。Ruby SDK 1.8.7-p302,带有Rails 3.0.3

我去过谷歌,有我的公钥和私钥 下一步告诉我应该将密钥添加到project/config/initializers/recaptcha.rb该文件中包含以下内容:

 Recaptcha.configure do |config|
  config.public_key = 'myKey'
  config.private_key = 'myKey'
 end
现在,我应该用以下工具来修复我的gemfile

 gem 'recaptcha', :require => 'recaptcha/rails'
我还有我的配置/application.rb阅读:

 require 'rails/all'
 require 'net/http'
我还向我的外部库/[gem]devise/app/views/devise/registrations/new.html.erb添加了recaptcha标签:

   <%= recaptcha_tags %>
   <p><%= f.submit "Sign up" %></p>
Project/config/routes.rb:

 devise_for :users, :controllers => {:registrations => 'registrations'}  
这就是它吐出的错误:

ActionController::RoutingError(未初始化的常量注册控制器):


呈现的C:/Ruby/lib/Ruby/gems/1.8/gems/actionpack-3.0.3/lib/action\u dispatch/middleware/templates/rescues/routing\u error.erb(0.0ms)。。。。。有什么想法吗

对于您的路由,您可以保留正常的设计路由,但指定自定义控制器除外:

devise_for :users, :controllers => {:registrations => 'registrations'}
在registrations_controller.rb中,您希望将design registrations controller子类化并覆盖“create”方法:

class RegistrationsController < Devise::RegistrationsController
    def create
        if verify_recaptcha then
            super
        else
            build_resource
            clean_up_passwords(resource)
            flash[:notice] = 'Invalid Captcha'
            render_with_scope :new
        end
    end
end
类注册控制器
对于您的路线,您可以保留正常的设计路线,但指定自定义控制器除外:

devise_for :users, :controllers => {:registrations => 'registrations'}
在registrations_controller.rb中,您希望将design registrations controller子类化并覆盖“create”方法:

class RegistrationsController < Devise::RegistrationsController
    def create
        if verify_recaptcha then
            super
        else
            build_resource
            clean_up_passwords(resource)
            flash[:notice] = 'Invalid Captcha'
            render_with_scope :new
        end
    end
end
类注册控制器
因此,在my registrations\u controller.rb中,我创建了当前的def…我要完全替换或添加到?嗯,您当前的注册控制器应该是Desive registrations controller的子类化,否则为空,除非您进行了其他自定义。如果已经定义了create方法,那么如果
verify\u recaptcha
返回false,则只需停止注册过程。因此,在我的注册\u controller.rb中,我有我当前的def create…我要完全替换或添加到?嗯,您当前的注册控制器应为Desive registrations controller的子类,否则应为空,除非您进行了其他自定义。如果已经定义了create方法,那么如果
verify\u recaptcha
返回false,则只需停止注册过程。