开发者

Rails 3: sign_up with Devise

I've a problem with registration of new user with devise. On my index page, I have this:

<%= link_to 'New User', new_user_registration_path %>

When I click on the link, the index page reloads. If I click on sign_up link on authentification page, there is no problem, but from the index page of an authenticated user, there is a problem. I see in the lo开发者_开发百科g:

Redirected to http://localhost:3000

This is the screen. The target is an admin can create a new user.


You could overwrite the Registrations Controller to sign out before sign up.

class Devise::RegistrationsController < ApplicationController
  […]

  # GET /resource/sign_up
  def new
    #OVERWRITE
    sign_out if current_user
    #END

    resource = build_resource({})
    respond_with_navigational(resource){ render_with_scope :new }
  end

  […]
end


It's because you are already logged in.

Go to this url: localhost:3000/users/sign_out

And then click your link.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜