0

I am creating my first every Rails site and I started using the Devise gem to create a login for myself, so I can add content (for example I want to add a new movie review).

Since I am the only one using the site - how do I hide and disable the sign_up URL so that no one else can sign up?

Do I just keep the "/users/sign_in" URL hidden so that only I know it? How do I prevent anyone else from signing up?

Is there a better way to do this without using devise?

Many Thanks

user3437721
  • 2,227
  • 4
  • 31
  • 61
  • Well, to me using devise to handle backend sign-up is an overkill as you don't need 99% of its features. Just use `has_secure_password`. – BroiSatse Mar 10 '15 at 16:11

1 Answers1

0

Just remove the :registerable from the model.

So

devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable  

becomes

devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable
aspencer8111
  • 786
  • 4
  • 9
  • Worth noting that you should only do this AFTER you have added yourself as a user in production. Or you can still add yourself as a user through Rails console whenever. – aspencer8111 Mar 10 '15 at 16:11
  • ok so I still login using the 'hidden' URL /users/sign_in? Also it errors when I try to sign out? – user3437721 Mar 10 '15 at 16:20
  • ya. you will still be able to login using that url. what is the error when you logout? – aspencer8111 Mar 10 '15 at 16:28
  • No route matches [GET] "/users/sign_out" – user3437721 Mar 10 '15 at 16:35
  • Did you change your routes.rb file at all? Put the ```:registerable``` module back. Does that fix the problem? – aspencer8111 Mar 10 '15 at 16:37
  • I put :registerable back but same error, I didn't change the routes file. Is it anything to to with a missing destroy path:
  • <%= link_to "Sign Out", destroy_user_session_path, method: :delete, class: "active" %>
  • – user3437721 Mar 10 '15 at 16:39
  • cant seem to find: destroy_user_session_path? – user3437721 Mar 10 '15 at 16:45
  • Go ahead and remove the ```:registerable``` module again. Was just making sure my advice didn't cause the error. It has to be an issue with your routes.rb file. Can you post it? – aspencer8111 Mar 10 '15 at 17:26
  • Rails.application.routes.draw do devise_for :users resources :movies # You can have the root of your site routed with "root" root 'movies#index' end – user3437721 Mar 11 '15 at 09:24