开发者

Using own registrations controller with Devise

I use devise for authentication. I wanted to use my own registrations controller instead of the one which devise uses internally. So went up and followed the instructions provided here, https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-edit-their-account-without-providing-a-password

Copy the registrations_controller.rb file from Devise (remember to copy the controller from the same devise version as your devise gem)

Place this into your /app/controllers directory.

In config/routes.rb add :controllers => { :registrations => "registrations" } to your devise_开发者_Go百科for root.

Make sure you name the file registrations_controller.rb

Change the first line: class Devise::RegistrationsController < ApplicationController to class RegistrationsController < ApplicationController

I use the devise version 1.1 and I copied the registrations_controller.rb file from here. https://github.com/plataformatec/devise/blob/v1.1/app/controllers/devise/registrations_controller.rb

Now, when I hit new action of the registrations controller, I get the below error

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'

My registrations_controller.rb looks exactly like the one from where i copied. what could be the problem? Thanks.


You are seeing the same exact issue at the person here:

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

Use the one from the 1.1.2 tag and it should work. This is assuming it was working with Devise's built-in controller and the model has the "registerable" module loaded.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜