In devise I'm trying to make it so that a Logged in user can create a new user via the Devise signup form.
Currently I've tried overriding the controller but it keeps redirecting me back to the root page due to me being logged in.
registrations_controller.rb
class RegistrationsController < Devise::RegistrationsController
skip_before_action :require_no_authentication, only: [:new, :create, :cancel]
protected
def create
User.create!({:email => params[:email], :roles => [''], :password => params[:password], :password_confirmation => params[:password_confirmation] })
end
def sign_up(resource_name, resource)
end
end
routes.rb
devise_for :users, controllers: { registrations: "registrations" }, skip: [:sessions]
Am I missing something obvious, because I assumed the code below would allow it so I could view the form when I'm logged in?
skip_before_action :require_no_authentication, only: [:new, :create, :cancel]
Solution:
I was being too specific in my signup route it was set as devise/registration#new instead of registrations#new
If anyone reading this in future gets stuck, let me know and i'll try my best to help! :)