Forum: Ruby on Rails problem w/shared partials

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.
500e92cfb666d6757c317a5df7c7e28d?d=identicon&s=25 Shawn Bright (nephish)
on 2007-01-18 15:59
ok, i am here again, i have been stumped on this since early afternoon.
so here goes.

i am trying to render a partial from two different controllers.
i have groups, and group has_many :sites

i have a main list in a group summary table with each linking
an action in the site_controller called display_site.
this brings a view of site details. now, i also need a page that shows
the details
of each site, one after another.

the link from the list in the /group/summary.rhtml looks like this:
<%= link_to site.site_name, :action => 'display_site',
                                        :id => ,
                                        :controller => 'site'%>

here is some of what i have, this is my most recent try.
i have tried render with collections, locals, :site => site, etc...
the display site link above works, but anything i try from the group
results in a blank page ( except the title and ) or
errors about nil.site_name

# in site_controller
def display_site
   @site = Site.find(params[:id])

# in the /group/details.rhtml
<% @group.sites.each do |site|  %>
<%= render(:partial => "shared/site", :locals => {:id => }) %>
<% end %>

# in /site/display_site.rhtml
<%= render(:partial => "shared/site",  :object => @site) %>

# finally, in the /views/shared/_site.rhtml
<%= site.site_name %>

i have been everywhere and i can't seem to pull this off, i have read
forum posts, the api,
tutorials at OnLamp, i even have the AWD book for crying out loud, and i
am banging my head here.

if you have read this far down, thanks for your time.
70ca58d0e0e0eabbdb74d177417d09d7?d=identicon&s=25 (Guest)
on 2007-01-18 17:02
(Received via mailing list)
Did you try render(:partial => "shared/site", :locals => {:site =>
@site}) ?

On Jan 18, 3:59 pm, Shawn Bright <>
500e92cfb666d6757c317a5df7c7e28d?d=identicon&s=25 Shawn Bright (nephish)
on 2007-01-18 17:16
no, i did not because i don't have @site from the group controller, but
i have @group.sites. It looks backwards. what does :site => @site part
do ?

and, in the partial, should i be using site or @site ?
The partial view i mean

thanks for looking at this

This topic is locked and can not be replied to.