Components and application.rhtml

Many of the screens in the app I’m working on are “portal” views with
little sidebar nuggets of information from elsewhere in the app.

I thought components would be perfect for that. For example for a
summary of user activity I could render_component(:controller => ‘user’,
:action => ‘stats_box’) or something similar.

The problem is that I have my page’s standard header and footer in
application.rhtml. When I render_component, it is rendered inside the
application.rhtml template. Since that contains header and footer, I
have nasty stuff like and in the middle of my page!

Of course I can get rid of application.rhtml and put my header and
footer in controller_name.rhtml or an explicit layout name but that
seems to violate DRY.

I must be missing something… any input appreciated! Thanks!

Carl J. wrote:

The problem is that I have my page’s standard header and footer in
application.rhtml. When I render_component, it is rendered inside the
application.rhtml template. Since that contains header and footer, I
have nasty stuff like and in the middle of my page!

Change the code so that that the component uses “nil” for the layout.

Eric

Change the code so that that the component uses “nil” for the layout.

Ah thanks… I’ll give that a shot. Though now that I am learning more
about displaying data from a bunch of different models, I think I am
going to try to switch to shared partials. I’ll have to compile the data
from the various sources all in one controller, but in the “rails way” I
don’t think that can be helped…

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs