Skip to content

Instantly share code, notes, and snippets.

@zernel
Created October 24, 2012 03:12
Show Gist options
  • Save zernel/3943463 to your computer and use it in GitHub Desktop.
Save zernel/3943463 to your computer and use it in GitHub Desktop.
Devise disable signup
devise_for :users, :skip => [:registrations]
as :user do
get 'users/edit' => 'devise/registrations#edit', :as => 'edit_user_registration'
put 'users' => 'devise/registrations#update', :as => 'user_registration'
end
# And then modify the app/views/devise/shared/_links.erb
@ldestrooper
Copy link

Thank you so much!!

@CoryFoy
Copy link

CoryFoy commented Oct 11, 2020

Another way to do it is to remove :registerable from your Devise model and all of this other stuff should happen automatically.

@reymillenium
Copy link

reymillenium commented Nov 16, 2020

Another way to do it is to remove :registerable from your Devise model and all of this other stuff should happen automatically.

If you remove registerable from the User model (in this case), then you wont be able to edit a user object. You won't be able to perform: edit_user_registration_path
The idea is to prevent from creating new users, not to also prevent from editing the already existing users.

@CoryFoy
Copy link

CoryFoy commented Nov 16, 2020

I guess it depends on what you're editing about them. Removing registerable still allows existing users to change their passwords and some other basic stuff, just not any stuff you have in registration like their email address or cancelling an account.

@pjmartorell
Copy link

I agree with @CoryFoy, removing :registerable from the model makes the sign up link not to be rendered in the form and the route not being generated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment