开发者

Is there a way in rails to intercept controller requests?

开发者 https://www.devze.com 2023-03-02 12:18 出处:网络
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 frame

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
0

精彩评论

暂无评论...
验证码 换一张
取 消