Where to put a before_filter shared between multiple controllers

后端 未结 4 704
旧巷少年郎
旧巷少年郎 2021-01-02 01:55

I have multiple controllers that all use an identical before_filter. In the interests of keeping things dry, where should this method live so that all the controllers can us

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-02 02:47

    If it is common to all controllers, you may put it in the application controller. If not, you can create a new controller and make it the superclass of them all and put the code in it.

提交回复
热议问题