I am using Devise
and change its default routes like this:
devise_for :users, :path => '',skip: [:sessions]
as :user do
get '/forgotten' => 'users/passwords#new', as: :password
post '/forgotten' => 'users/passwords#create'
put '/forgotten' => 'users/passwords#update'
get '/password/edit' => 'users/passwords#edit'
end
The generated URL (form action attribute) for new.html.erb
(view for sending email with new password instructions) is /forgotten.user
, which is not correct. The correct URL is /forgotten
and it is used with different HTTP verbs GET/POST/PUT. In request new password form (new.html.erb):
<%= form_for(resource, as: resource_name,
url: password_path(resource_name), html: { method: :post})
Without my custom routes with rake routes
, I see for these routes:
user_password | PATCH | /password(.:format) | users/passwords#update
PUT | /password(.:format) | users/passwords#update
POST | /password(.:format) | users/passwords#create
How to make this route custom and used for different HTTP verbs ?
Aucun commentaire:
Enregistrer un commentaire