If a view file cannot be compiled (eg it has a block with a missing
'end' statement), I'm experiencing WSODs - the browser reports a lost
network connection, rather than the helpful compilation error that we
used to have.
When the compilation fails, ActionView#compile_template raises this
TemplateError.new(find_base_path_for(file_name || template), file_name
template, @assigns, template, e)
...which appears to have a few things wrong with it.
First off, file_name is always absolute here - eg /Users/jon/
is going to fail since it tries to append that path onto the path from
@view_paths - typically /Users/jon/Developer/Stacker/app/views.
So, find_base_path_for returns nil. I *think* what happens is that
code inside template_error.rb later raises a second exception when it
tries to use that path as a string and finds it's nil, and that
exception isn't caught properly, so the response is never formed,
which produces the WSOD. If I replace it with
TemplateError.new(find_base_path_for(file_name || template) || "",
file_name || template, @assigns, template, e)
the compilation error is reported properly.
The reason I'm posting here rather than submitting a patch to Trac is
that I'm struggling to understand a few things about that line of
code, and so I'm not sure of the best way to fix it.
'template' is the contents of the template file. So why are we trying
to use it as a filename for find_base_path_for()? Is it supposed to
be find_base_path_for(file_name) || template ? If so, why are we
creating a TemplateError with base_path=<file contents> ? Same
applies to the second parameter - if file_name is nil, use the
Why is find_base_path_for being used at all? Why not File.dirname ?
Thanks for any help figuring this out...