What order do before filters occur in?

后端 未结 3 776
孤街浪徒
孤街浪徒 2020-12-18 19:05

What order do before filters occur in? Specifically, what order do the before_action filters occur in, in regards to inheiritance? For example, will this work:



        
3条回答
  •  一生所求
    2020-12-18 19:44

    Yes, your code will work as intended.

    The before_filters on the derived class (B) are called before the before_filters on the base class (A). So the order of the methods called are:

    1. set_user()
    2. set_post()
    3. show()

    Also note, after_filters are called in reverse order, the most derived first.

提交回复
热议问题