使用自己的注册控制器与Devise

时间:2011-02-21 04:51:59

标签: ruby-on-rails ruby authentication

我使用设计进行身份验证。我想使用我自己的注册控制器,而不是内部设计使用的控制器。所以上去按照这里提供的说明https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-edit-their-account-without-providing-a-password

从Devise复制registrations_controller.rb文件(记得从与设计宝石相同的设计版本复制控制器)
将其放入/ app / controllers目录。
在config / routes.rb中添加:controllers => {:registrations => “注册”}到你的devise_for root 确保将文件命名为registrations_controller.rb
更改第一行:class Devise :: RegistrationsController< ApplicationController到类RegistrationsController< ApplicationController

我使用了设计版本1.1,我从这里复制了registrations_controller.rb文件。 https://github.com/plataformatec/devise/blob/v1.1/app/controllers/devise/registrations_controller.rb

现在,当我点击注册控制器的新动作时, 我收到以下错误

NoMethodError (undefined method `new_with_session' for User:Class):
app/controllers/registrations_controller.rb:71:in `build_resource'
app/controllers/registrations_controller.rb:8:in `new'

我的registrations_controller.rb看起来与我复制的地方完全一样。 可能是什么问题呢?感谢。

1 个答案:

答案 0 :(得分:1)

您在此处看到同样的问题:

http://groups.google.com/group/plataformatec-devise/browse_thread/thread/9733963d63a8a77a

使用1.1.2标签中的标签,它应该有效。这是假设它正在使用Devise的内置控制器,并且该模型已加载“可注册”模块。