How to call mutiple actions in one layout

hi

for a few days now I am searching for a solution for this problem:

I would like to render multiple actions in a layout.

For example:
I have in the welcome layout two divs:
1 menubar and a main.

the menu bar has his one controller with the action: list
and the main has a controller (for example: article_controller.rb) with
the action: list.

both of the actions I want it to be used when the page is loading but i
dont now how.
I now i can use <%= yield :layout %> for the main. But then I dont
render the menu.

can I render the action: list in menu when the page is loaded ?
then call the action: list in article…

I hope you understand my problem (it was hard to explain :stuck_out_tongue: )

Heldop S. wrote:

hi

for a few days now I am searching for a solution for this problem:

I would like to render multiple actions in a layout.

For example:
I have in the welcome layout two divs:
1 menubar and a main.

the menu bar has his one controller with the action: list
and the main has a controller (for example: article_controller.rb) with
the action: list.

use iframes

walla. you can style the iframes so they have no border, etc; basically,
this is (definitely) the way to go.

enjoy
shai

Shai R. wrote:

Heldop S. wrote:

hi

for a few days now I am searching for a solution for this problem:

I would like to render multiple actions in a layout.

For example:
I have in the welcome layout two divs:
1 menubar and a main.

the menu bar has his one controller with the action: list
and the main has a controller (for example: article_controller.rb) with
the action: list.

use iframes

walla. you can style the iframes so they have no border, etc; basically,
this is (definitely) the way to go.

enjoy
shai

THANXS !!

ok well meanwhile I did some thinking and came up with this solution:

create a helper method (for example article_helper.rb and create an
action (for example “list_article”).
in application.rb you put helper :article

ok if you now call <%= list_article %> you call the action in
article_helper.

which solution would be best?
and why ?

Frederick C. wrote:

which solution would be best?
and why ?

Sorry for my previous truncated reply!
That won’t work well because you can only call render (except
partials) once per action.

The better way to go with these things is a combination of helpers and
partials, eg have a render_menu_bar helper.

Fred

hehe…yes I tryed it but didn’t work…

thanxs though, for the reply

I suspect what you really want is nested layouts:

http://agilewebdevelopment.com/plugins/nested_layouts

good luck!
Tim

Heldop S. wrote:

hi

for a few days now I am searching for a solution for this problem:

I would like to render multiple actions in a layout.

For example:
I have in the welcome layout two divs:
1 menubar and a main.

the menu bar has his one controller with the action: list
and the main has a controller (for example: article_controller.rb) with
the action: list.

both of the actions I want it to be used when the page is loading but i
dont now how.
I now i can use <%= yield :layout %> for the main. But then I dont
render the menu.

can I render the action: list in menu when the page is loaded ?
then call the action: list in article…

I hope you understand my problem (it was hard to explain :stuck_out_tongue: )

which solution would be best?
and why ?

Sorry for my previous truncated reply!
That won’t work well because you can only call render (except
partials) once per action.

The better way to go with these things is a combination of helpers and
partials, eg have a render_menu_bar helper.

Fred

I would like to render multiple actions in a layout.

For example:
I have in the welcome layout two divs:
1 menubar and a main.

the menu bar has his one controller with the action: list
and the main has a controller (for example: article_controller.rb) with
the action: list.

both of the actions I want it to be used when the page is loading but i
dont now how.
I now i can use <%= yield :layout %> for the main. But then I dont
render the menu.

can I render the action: list in menu when the page is loaded ?
then call the action: list in article…

I hope you understand my problem (it was hard to explain :stuck_out_tongue: )

I don’t think I’d call that rendering multiple “actions,” but rather
that you have multiple objects you want rendered to the screen.

Eventually you’ll have all kinds of things you want drawn to screen that
come from multiple objects.

It is the job of the action for the controller of the route to
instantiate all the objects needed into instance vars which can then be
used by views, partials, layouts.

Have a look at this article:

http://www.railsdev.ws/blog/3/modular-page-assembly-in-rails/

It explains techniques for getting data into your layouts.

– gw