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

Ask A Question

Notifications

You’re not receiving notifications from this thread.

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

Alan Reid asked in Rails

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.

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 37,344+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.