How/when the 'after_filter' works/runs?

后端 未结 2 1147
闹比i
闹比i 2021-02-18 21:59

I am using Ruby on Rails 3.1 and I would like to know (for performance reasons) whether or not the after_filter runs after that view files are rendered. Th

2条回答
  •  南笙
    南笙 (楼主)
    2021-02-18 22:12

    You have to be aware that a request to your server is fully consistent and runs in its own thread.

    If you put code in an after_filter, this will delay the whole request: to sum up badly, if the thread is alive, the page is not delivered.

    That's why you find great plugins like DelayedJob and Resque, they work in a parallel processes and won't affect your app.


    To answer your original question , after_filter are triggered after the view has been processed.

    This is sometimes a hassle that's why people created some before_render filters.

提交回复
热议问题