Fix template assertion when opening a session.

Resolves https://github.com/rails/rails/pull/16234#commitcomment-7115670

@senny @rubys
:+1: