Forum: Ruby on Rails Problem rendering components

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Daniel S. (Guest)
on 2006-03-10 23:12
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

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?
This topic is locked and can not be replied to.