如何申请的before_filter在Rails的3.2.11每个控制器的每一个动作? [英] How to apply before_filter to every action of every controller in Rails 3.2.11?
本文介绍了如何申请的before_filter在Rails的3.2.11每个控制器的每一个动作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想验证,如果用户登录上的每一个请求到服务器。
I'd like to verify if the user is logged in on every single request to the server.
是这样的:
:before_filter verify_logged_in
我应该在哪里把那个的before_filter所以它适用于所有的控制器动作,所有的请求?
Where should I put that before_filter so it applies to all controller actions and all requests?
推荐答案
要确保过滤器适用于所有的行动,将其放置在application_controller.rb。
To ensure that filters apply to all actions, place it in the application_controller.rb.
这篇关于如何申请的before_filter在Rails的3.2.11每个控制器的每一个动作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文