Forum: Ruby on Rails partials with action methods?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
689107856b5a794181624031eb6df776?d=identicon&s=25 flukus@gmail.com (Guest)
on 2007-02-18 12:36
(Received via mailing list)
I have a pretty standard partial for my sidebar that I want to display
the login form etc if the user is not logged in and if they are then
display the relevant links.

As far as I can tell, calling render :partial does not trigger methods
in the controller class. So how do I get application data into the
partial.

The partial is invoked by the layout, which doesn't have access to
controller functions so they only way I can see around this is to
create the required objects in a befor_filter.

Is there a more elegant way to do this? without render_component?
6d57db44c5a4e0721cc7f78cf0ce308a?d=identicon&s=25 Stephen Bartholomew (steveb)
on 2007-02-18 12:42
(Received via mailing list)
> The partial is invoked by the layout, which doesn't have access to
> controller functions so they only way I can see around this is to
> create the required objects in a befor_filter.
Yeah - use a before filter to load the data you need for the sidebar,
then use a helper or partial to display it.

Steve
This topic is locked and can not be replied to.