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 site.name linking
to
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 => 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
controller
results in a blank page ( except the title and group.name ) or
errors about nil.site_name
# in site_controller
def display_site
@site = Site.find(params[:id])
end
# in the /group/details.rhtml
<% @group.sites.each do |site| %>
<%= render(:partial => "shared/site", :locals => {:id =>
site.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.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
augustlilleaas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jan-18 16:01 UTC
Re: problem w/shared partials
Did you try render(:partial => "shared/site", :locals => {:site
=>
@site}) ?
On Jan 18, 3:59 pm, Shawn Bright
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> 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 site.name linking
> to
> 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 => 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
> controller
> results in a blank page ( except the title and group.name ) or
> errors about nil.site_name
>
> # in site_controller
> def display_site
> @site = Site.find(params[:id])
> end
>
> # in the /group/details.rhtml
> <% @group.sites.each do |site| %>
> <%= render(:partial => "shared/site", :locals => {:id
=> site.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.
>
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
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 sksk -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---