开发者

Devise: Overriding create action in Registrations Controller for Recaptcha

I'm trying to override the create method from the Registrations Controller in Devise to include Recaptcha verification (as seen here and here):

class RegistrationsController < Devise::RegistrationsController

  def create
    if verify_recaptcha
      super
    else
      build_resource
      clea开发者_如何学JAVAn_up_passwords(resource)
      flash[:alert] = "Bad words."
      render_with_scope :new
    end
  end

end

Also changed my routes.rb accordingly:

  map.devise_for :users, :controllers => {:registrations => "registrations"}, :path_names => {
    :sign_up => 'signup',
    :sign_in => 'login',
    :sign_out => 'logout'
  }

When trying to visit the new registration page (with new path name: http://localhost:3000/users/signup) this errors shows up:

LoadError in RegistrationsController#new

Expected /home/benoror/project/app/controllers/registrations_controller.rb to define RegistrationsController

FULL ERROR TRACE

Any help appreciated.

BTW, I'm using Devise 1.0.11 and Rails 2.3.10, thanks!


Is your controller in a Users module? If so, you will need

class Users::RegistrationsController
and

{:registrations => "users/registrations"}

Edit: According to José Valim, custom controllers don't work prior to Devise 1.1. No reason to be developing on < Rails 3 imho. Sorry I missed that in the original post.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜