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 want:
How can I do this?
Currently, I'm effectively removing this route by placing the following before devise_for :users
:
match 'users/sign_up' => redirect('/404.html')
That works, but I imagine there's a better way, right?
As Benoit Garret said, the best solution in my case is to skip creating the registrations routes en masse and just create the ones I actually want.
To do that, I first ran rake routes
, then used the output to re-create the ones I wanted. The end result was this:
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
Note that:
:registerable
in my User
modeldevise/registrations
handles updating email and passwordRemove the route for the default Devise paths; i.e.:
devise_for :users, path_names: {
sign_up: ''
}
I tried to do this as well, but a thread on the devise google group dissuaded me from searching for a really clean solution.
I'll quote José Valim (the Devise maintainer) :
There isn't a straight-forward option. You can either provide a patch or use :skip => :registerable and add only the routes you want.
The original question was :
Is there any good way to remove a specific route (the delete route) from Rails?