So you are trying to use the sign-up page of Devise and restrict the access to members only.
Devise only does authentication out of box. It's not aware of cancancan abilities or any other user logic you might have introduced. Thus, what you want won't work out of box.
You need to expose controllers and overwrite the sign-up controller. You can use
rails generate devise:controllers users
if your devise user schema is users
. Please refer to devise documentation for the actual command reference. Then you can customize the registration controller.
What I'd prefer doing here would be using both ability and authentication checks as controller actions.
class Devise::RegistrationsController < DeviseController
...
before_action :authenticate_user!
load_and_authorize_resource
However you can do anything you want. That is the part you will want restrict the access. You can relate to rolify or any other component of your application.
That's basically what you ask. But, I would recommend not to take this way.
I've had a similar experience with a project I'm working on. I was trying to build an admin based add-user page and tried to use the devise registration pages as base and modify them.
However what I experienced was customizing these controllers and views (especially controllers) is getting cumbersome when you begin to change the actual dynamics of the page. You might find yourself digging deeper and deeper to ensure that whole authentication model runs without any problems.
Instead what I did was to introduce my own controller. Since devise exposes the authentication model and methods it's fairly easy to do standard task such as adding, removing and updating users. Your controllers will be very trivial, in fact with cancancan it might be enough to write a skeleton controller (with no method body) using load_and_authorize_resource
that handles resource operations automatically.
You can replicate views of devise and use with this controller. This way you provide a similar frontend experience with devise.
Most important merit in this approach is you do not extend devise and leave it to work as a component. Thus, anything that will change in your project or in devise will not affect you much.