rails:3 Devise signup Filter chain halted as :require_no_authentication rendered or redirected

The mentioned line on Devise's Controller makes sense in general cases: a logged in user can't sign up. As you're on a case where only an admin can create a user, I would suggest that you don't use Devise's controller on Registerable module and write your own controller with your own rules. You can write it based on Devise's controller changing only the mentioned line.

If you want to use it, try skipping the before_filter with skip_before_filter. I don't think it is the best solution. and I would write my own controller.


I was receiving the following error in my development log.

Filter chain halted as :require_no_authentication

An endless loop was created because devise's after_sign_in_path_for in application_controller.rb was redirecting back to the previous page with

stored_location_for(resource)

Devise's gem signs in the user when the password is edited.


Like you, I wanted an Admin user to be able to add new users. But I didn't want to mess with the Devise Registerable, since I actually wanted users to still be able to register themselves. I have some admin users with permission to add a new user, so I created additional methods in my users controller and additional views to handle that case.

My additional methods are not referenced by Devise's prepend_before_filter :require_no_authentication, so they don't get the error.

My recipe:

In app/controllers/users_controller.rb (or whatever object you are using devise for): Copy the new, create and update methods and rename the copies to admin_new, admin_create, and admin_update.

In app/views/users, copy new.html.erb to admin_new.html.erb Change the partial to refer to admin_form instead of form:

 <%= render 'admin_form' %>

Then copy the partial _form.html.erb to _admin_form.html.erb. In _admin_form.html.erb, change the form_for to use a different URL:

form_for(@user, :url => '/users/admin_create')

Add routes in config/routes.rb to point to the alternate methods in the user controller:

devise_scope :user  do
    ...
    get  'users/admin_new' => 'users#admin_new'
    post 'users/admin_create' => 'users#admin_create'
end

Now you can add users while you are logged in by going to /users/admin_new, and users are still able to create their own user (register) using the devise mechanism that you have not disturbed.