Skip to main content

How do I get devise to use my custom routes inside of the authenticate_user!

Rails • Asked by Alan Reid

I've declared custom routes in my app for a few of the devise actions, they are as follows:

devise_scope :user do
  get 'signup', to: 'devise/registrations#new', as: :signup
  get 'login', to: 'devise/sessions#new', as: :login
  get 'logout', to: 'devise/sessions#destroy', as: :logout
  get 'forgotten', to: 'devise/passwords#new', as: :forgotten
  get 'resend-confirmation', to: 'devise/confirmations#new', as: :resendconfirmation
end

However, when an unauthenticated user accesses a protected part of my site still gets redirected to /users/sign_in. How do I get devise to use my custom routes inside of the authenticate_user! before_action? to keep the whole experience of using my app the same.

Thanks all.


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.