How do I remove the Devise route to sign up?

后端 未结 15 2345
佛祖请我去吃肉
佛祖请我去吃肉 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:27

    Do This in routes.rb

    devise_for :users, :controllers => {:registrations => "registrations"}, :skip => [:registrations]
      as :user do
        get 'users/edit' => 'devise/registrations#edit', :as => 'edit_user_registration'
        put 'users' => 'devise/registrations#update', :as => 'user_registration'
    end
    
      devise_scope :user do
        get "/sign_in",  :to => "devise/sessions#new"
        get "/sign_up",  :to => "devise/registrations#new"
      end
    

    you will get an error now while you come to sign in page, to fix it. Do this change in: app/views/devise/shared/_links.erb

    <% if  request.path != "/sign_in" %>
        <%- if devise_mapping.registerable? && controller_name != 'registrations' %>
            <%= link_to "Sign up", new_registration_path(resource_name) %>
    <% end -%> <% end %>

提交回复
热议问题