I’m using Devise’s built in before_filter :authenticate_user!. I want to call my own custom method in my application helper if a user fails the before filter (tries to do an action when logged out). How and where can I do this?
I’m using Devise’s built in before_filter :authenticate_user! . I want to call my own
Share
I would write a custom before filter that uses
user_signed_in?. This will just return a boolean, and not do any of the redirect-type actions thatauthenticate_user!does.So, you could write a before filter like this:
Do note that this before filter won’t protect your resource from unauthorized users unless the inside area of that
unlessstatement redirects or renders.