How do I remove the Devise route to sign up?

后端 未结 15 2334
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-07 07:36

I\'m using Devise in a Rails 3 app, but in this case, a user must be created by an existing user, who determines what permissions he/she will have.

Because of this, I

15条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-07 08:28

    I liked @max's answer, but when trying to use it I ran into an error due to devise_mapping being nil.

    I modified his solution slightly to one that seems to address the issue. It required wrapping the call to resource inside devise_scope.

    devise_for :users, skip: [:registrations]
    
    devise_scope :user do
      resource :users,
               only: [:edit, :update, :destroy],
               controller: 'devise/registrations',
               as: :user_registration do
        get 'cancel'
      end
    end
    

    Note that devise_scope expects the singular :user whereas resource expects the plural :users.

提交回复
热议问题