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

Ticket #8737 (new defect)

Opened 1 year ago

Last modified 1 year ago

[PATCH] Test for broken layout hierarchy

Reported by: lifofifo Assigned to: core
Priority: normal Milestone:
Component: ActionPack Version: edge
Severity: normal Keywords:
Cc: nicwilliams, mikong

Description

Ticket 3647 points out that layout breaks when controllers are inherited. I am still stumbling to figure out if it's bug or expected behavior. I've added a test case to explain failing behavior. If it's bug, I'd be happy to submit a patch.

Thanks.

Attachments

layout_broken_with_only.diff (1.1 kB) - added by lifofifo on 06/24/07 18:09:11.
Test case for when inherited layouts break with :only option

Change History

06/24/07 18:09:11 changed by lifofifo

  • attachment layout_broken_with_only.diff added.

Test case for when inherited layouts break with :only option

06/24/07 21:35:43 changed by nicwilliams

  • cc set to nicwilliams.

I think this is a bug - if an action doesn't qualify for the layout conditions, then any superclass's layout specifications should be used/tested before returning nil/application.rhtml

06/24/07 21:40:14 changed by lifofifo

A simple pastie to explain the behavior.

(follow-up: ↓ 5 ) 07/14/07 18:13:15 changed by mikong

In my opinion, this is expected behavior because in the documentation of layout inheritance, a child controller's layout declaration overrides the parent layout. I think they were not designed to work together, as the implementation of layout simply resets the "layout" inheritable attribute in the hash. There's no attempt to monitor layout conditions of multiple layout attributes.

But I think it's a good enhancement to have layout declarations with conditions in a layout hierarchy work together. It may be better to implement a plugin first since the change doesn't seem to be trivial.

This is sort of related to a more recent ticket #8867 I'm currently checking, where the problem is that multiple layouts were called in a single controller and both with layout conditions, and an unexpected behavior occurred.

07/14/07 18:13:57 changed by mikong

  • cc changed from nicwilliams to nicwilliams, mikong.

(in reply to: ↑ 3 ) 07/14/07 18:34:01 changed by mikong

Replying to mikong:

I think they were not designed to work together, as the implementation of layout simply resets the "layout" inheritable attribute in the hash. There's no attempt to monitor layout conditions of multiple layout attributes.

Sorry, at this part I was thinking in the context of #8867 wherein the layout was called twice in the same controller and resetting the "layout" attribute leaves no info about the previous value. In a layout hierarchy, the superclass's layout specs can still be checked. My bad.