Replace before_finish with before_rendered.