How/when the 'after_filter' works/runs?

后端 未结 2 1146
闹比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:32

    after_filter is run after the content has been generated, but before it's been sent to the client. You can verify this is so because you have access to the completely-generated response data in the response method of your controller in any after_filter.

    After_filters are inappropriate places to put long running tasks as they will definitely impact the users' experience. Consider instead using the after_filter to kick off a long running delayed_job or resque task to perform your background work instead.

提交回复
热议问题