Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #1115 (closed defect: fixed)

Opened 3 years ago

Last modified 2 years ago

[PATCH] Errors in a layout file cause template_error.rhtml to be unrenderable

Reported by: Michael Schubert <michael@schubert.cx> Assigned to: David
Priority: high Milestone: 1.0
Component: ActiveRecord Version: 0.11.0
Severity: major Keywords: template layout
Cc: michael@schubert.cx

Description

Suppose you've got an error in your layout file, when you try render an action that uses that layout, instead of getting the error page pointiing out the problem, template_error.rhtml blows up because @request.parameterscontroller? is nil and you can't capitalize nil.

On line #3 of /Users/schubert/Sites/weird/public/../config/..//vendor/rails/actionpack/lib/action_controller/templates/rescues/template_error.rhtml

    1: <h1>
    2:   <%=h @exception.original_exception.class.to_s %> in
    3:   <%=h @request.parameters["controller"].capitalize %>#<%=h @request.parameters["action"] %>
    4: </h1>
    5: 
    6: <p>

    (erb):3:in `evaluate_locals'
]]}

The line in question:

{{{
<%=h @request.parameters["controller"].capitalize %>#<%=h @request.parameters["action"] %>
}}}

The fix (well my fix) is just to check if its null, if so, don't try to capitalize it, e.g.:

{{{
<%=h @request.parameters["controller"].capitalize if @request.parameters["controller"] %>#<%=h @request.parameters["action"] %>
}}}

Attachments

.2 (0 bytes) - added by Michael Schubert <michael@schubert.cx> on 04/15/05 15:34:40.
Attached patch that seems to fix the problem by not trying to capitalize the controller param if it is nil
template_error_rhtml.patch (0.5 kB) - added by Michael Schubert <michael@schubert.cx> on 04/15/05 15:35:12.
(... it would help if I actually attached the file) Attached patch that seems to fix the problem by not trying to capitalize the controller param if it is nil

Change History

04/15/05 15:23:24 changed by Michael Schubert <michael@schubert.cx>

Grmble stupid wiki editing truncated my code paste. Here we go again:

On line #3 of /Users/schubert/Sites/weird/public/../config/..//vendor/rails/actionpack/lib/action_controller/templates/rescues/template_error.rhtml

    1: <h1>
    2:   <%=h @exception.original_exception.class.to_s %> in
    3:   <%=h @request.parameters["controller"].capitalize %>#<%=h @request.parameters["action"] %>
    4: </h1>
    5: 
    6: <p>

    (erb):3:in `evaluate_locals'

04/15/05 15:34:40 changed by Michael Schubert <michael@schubert.cx>

  • attachment .2 added.

Attached patch that seems to fix the problem by not trying to capitalize the controller param if it is nil

04/15/05 15:35:12 changed by Michael Schubert <michael@schubert.cx>

  • attachment template_error_rhtml.patch added.

(... it would help if I actually attached the file) Attached patch that seems to fix the problem by not trying to capitalize the controller param if it is nil

04/16/05 23:53:06 changed by nzkoz

  • summary changed from Errors in a layout file cause template_error.rhtml to be unrenderable to [PATCH] Errors in a layout file cause template_error.rhtml to be unrenderable.
  • milestone set to 1.0.

When you add a patch, please start the summary with [PATCH] to ensure it gets reviewed.

04/17/05 06:11:52 changed by david

  • status changed from new to closed.
  • resolution set to fixed.