Is there a way in rails to intercept controller requests?
I don't think Rails calls it an interceptor, but I don't know what to search for.
In Java/Spring, you can create Interceptors that are called before and after any controller action in the MVC framework. This makes it easy to add data to 开发者_StackOverflowthe model for every request, so you don't have to keep adding it to each of your 50 controllers.
I have to take a wild guess and say Rails has something to do achieve the same effect... but I have no idea what it is called.
Care to share? :)
What you are looking for is called Filters.
- ActionController::Filters::ClassMethods
- Rails Guide
精彩评论