开发者

Problem overriding Devise::RegistrationsController

I've read similar articles like Override devise registrations controller , but Devise in my app doesn't override correctly.

I am using Devise 1.4.2 and Rails 3.0.9 on my Mac (OSX 10.6.8).

# app/controllers/registrations_controller.rb
class RegistrationsController < Devise::RegistrationsController
  def new
    debugger
  end

  def create
    debugger
  end
end

# config/routes.rb
devise_for :users, :controllers => {:registrations => "registrations"}

Then I started my local server with --debugger option (ruby-debug19 is installed) and when access to /users/sign_up, debugger doesn't trigger.

rails server --debugger

Started GET 开发者_JAVA技巧"/users/sign_up" for 127.0.0.1 at 2011-07-11 21:21:46 +0900
Processing by Devise::RegistrationsController#new as HTML
Rendered devise/shared/_links.erb (3.8ms)
Rendered devise/registrations/new.html.erb within layouts/application (20.4ms)

Updated: I checked my routings with "rake routes", but the routing for sign_up still remains as below.

user_registration POST /users(.:format) {
    :action=>"create", :controller=>"devise/registrations"}
new_user_registration GET /users/sign_up(.:format) {
    :action=>"new", :controller=>"devise/registrations"}

I want :controller to point "registrations" (without "devise/") when POST. What am I missing?


In your routes.rb file,

You can amend your devise routes in the following way:

devise_for :users, :controllers => { :registrations => 'registrations' }
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜