i got some trouble adding an action in my devise controller.
I created a controller named registrations_controller
in a folder users/
like this:
class Users::RegistrationsController < Devise::RegistrationsController
And, there is my route file:
root to: 'home#index'
devise_for :users
devise_scope :users do
get 'users/profil/:id', to: 'users/registrations#profil', as: 'profil'
end
And I see the following error:
Unknown action
Could not find devise mapping for path "/users/profil/1"
This may happen for two reasons: 1) You forgot to wrap your route inside the scope block. For example: devise_scope :user do get "/some/route" => "some_devise_controller" end 2) You are testing a Devise controller bypassing the router.
What's wrong with my code?
Try the following:
devise_scope :user do
get 'users/profil/:id', to: 'users/registrations#profil', as: 'profil'
end
devise_for :users, :controllers => {:registrations => "users/registrations"}
resources :users
Also you don't need to name the controller Users::RegistrationsController
keep it named as RegistrationController
keeping the inheritance as you have Devise::RegistrationsController
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With