before_filter with devise

前端 未结 2 1568
无人及你
无人及你 2021-01-02 03:01

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

2条回答
  •  余生分开走
    2021-01-02 03:53

    Instead of calling before_filter :authenticate_user! write your own function in your controller that calls authenticate_user!. Something like:

    before_filter :logged_in
    
    ...
    
    private
    def logged_in
      your_function
      authenticate_user!
    end
    

提交回复
热议问题