设计,不能使用自定义控制器动作

时间:2012-10-14 10:43:06

标签: ruby-on-rails ruby-on-rails-3

我按照devise page上的说明进行操作。唯一不同的是我正在定制注册,他们的例子是在会话上。

当我点击/users/sign_up页面时,设计正在使用Devise::RegistrationsController#new操作,而不是来自new的{​​{1}}操作

从下面的服务器日志中可以看到,即使用户控制器users_controller.rb行动XXXXXXXXXX\nxxxxxxxxxxx

,也看不到new
puts "XXXXXXXXXX\nxxxxxxxxxxx"

users_controller.rb

Started GET "/users/sign_up" for 127.0.0.1 at 2012-10-14 03:29:52 -0700
Processing by Devise::RegistrationsController#new as HTML
  Rendered /Users/jasonkim/.rvm/gems/ruby-1.9.3-p0/gems/devise-2.1.2/app/views/devise/shared/_links.erb (0.4ms)
  Rendered users/registrations/new.html.haml within layouts/application (4.8ms)
Completed 200 OK in 88ms (Views: 12.3ms | ActiveRecord: 0.7ms)

的routes.rb

class Users::RegistrationsController < Devise::RegistrationsController
  def new
    @user = User.new
    address = @user.address.build
    puts "XXXXXXXXXX\nxxxxxxxxxxx"
  end
end

我在devise.rb

中添加了唯一的东西
devise_for :users, :controllers => { :registration => "users/registration" }
devise_for :employers

我错过了什么?

1 个答案:

答案 0 :(得分:0)

应该是

devise_for :users, :controllers => { :registrationS => "users/registrationS" }

尾随's'(但当然是小写)