Problem rendering components


#1

I have an AccountsController that inherits from ApplicationController.
In ApplicationController I define a generic layout. In this layout I
render @title that is actually assigned in the AccountsController but
has a default value in ApplicationController.

In the layout template, I also have the standard contents_for_layout and
lastly, I have a render_component. The component called from the layout
template also renders @title.

The problem I have is that when the requested view renders (e.g.
/accounts/list), the @title defined in the layout template renders the
correct value defined in AccountsController. However, the @title defined
in the components template renders the value defined in
ApplicationController.

Isnt’ everything supposed to be rendered in the context of the
controller/action requested?

rhalff commented on the IRC:
rhalff: dsalama, but a component is a controller itself, so it uses that
context. your component probably extends application controller and you
didn’t set a title in the component controller itself.

To which I replied:
dsalama: rhalff: you just hit the nail in the head. You are right. A
component is a controller. From that PoV, it makes sense. However, it
kind of makes components a little less useful, IMHO. I should be able to
re-use a component within the context that I want to reuse it in.

Any comments?