Elmar Schraml wrote:
Hi,
maybe this has come up before, but a search turned up nothing useful...
Lately I'm getting the 500 error page whenever something goes wrong,
for any kind of error,
instead of the standard error page with explanation, stack trace, line
number etc.
I'm not aware of changing anything in the configuration.
I'd be really grateful for any tips on how to get my detailed error
pages back for debugging.
Thanks in advance,
Elmar
My configuration: Suse Linux , ruby 1.8.5, rails 1.1.6, server on
localhost:8080 started from within radrails 0.7.1
I was having the same problem and with a little debugging I determined
it was due to my config.action_view.erb_trim_mode setting in
config/environment.rb.
After a little research, I discovered the following:
If the ERB::Compiler::TrimScanner#explicit_trim_line is not invoked,
Rails (1.1.6|EDGE) rescue template craps out and doesn't show the
stack trace. Instead, the public/500.html page is displayed. I believe
this is because the omittance of the newline will place serveral lines
of Ruby code on a single line and cause compiler/parse errors.
If using '<' or '<>', you will have to strategically place
newlines in your templates. Otherwise, you must invoke the
explicit_trim_line method, which is enabled by including a hyphen in
config.action_view.erb_trim_mode.
All possible values for erb_trim_mode:
1. 1
2. 2
3. 0
4. nil
5. '%'
6. '%-'
7. '%>'
8. '%<>'
9. '-' (Rails default)
10. '>'
11. '<>'
The source for ERB can be found in ruby-1.8.4/lib/erb.rb.
I've included an interesting method:
def prepare_trim_mode(mode)
case mode
when 1
return [false, '>']
when 2
return [false, '<>']
when 0
return [false, nil]
when String
perc = mode.include?('%')
if mode.include?('-')
return [perc, '-']
elsif mode.include?('<>')
return [perc, '<>']
elsif mode.include?('>')
return [perc, '>']
else
[perc, nil]
end
else
return [false, nil]
end
end
Other interesting methods include:
1. explicit_trim_line (invoked by specifying a hyphen)
2. trim_line1 (invoked by specifying '%>' or '>' or 1)
3. trim_line2 (invoked by specifying '%<>' or '<>' or 2)
4. TrimScanner#initialize
-pachl