Hi All, I am trying to make use of the new render partial functionality where in the index view I have <%= render :partial => @people%> #in rails 2.0 it detects this as a collection and in the show <%= render :partial => @person%> #in rails 2.0 it detects this as an object The _person.html.erb partial is <td><%=h person.first_name %></td> <td><%=h person.last_name %></td> However I would like in the index view to add links to show or destroy and in the show view add an edit link. I tried to use the new layout for partials feature <%= render :partial => @people, :layout => ''index''%> <%= render :partial => @people, :layout => ''show''%> where the _index.html.erb contained the show and destroy links and the _show.html.erb contains the edit link. However for the layout it only seems to be rendered once for a collection not once for each object in the collection. Am I doing something wrong or is there a neat way round this. Thanks Anthony --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
thatcher.craig-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Jan-22 17:41 UTC
Re: Partials, Layouts and Collections
you''ll need to place the @people collection into a "for" statment and iterate through them, you''ll see similar contructs in the index.html.erb if you scaffold. <% for person in @people %> <%= h(person.first_name) %> etc..... <% end %> On Jan 22, 9:53 am, Ant <email2a...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi All, > I am trying to make use of the new render partial functionality where > in the index view I have > > <%= render :partial => @people%> #in rails 2.0 it detects this as a > collection > > and in the show > > <%= render :partial => @person%> #in rails 2.0 it detects this as an > object > > The _person.html.erb partial is > > <td><%=h person.first_name %></td> > <td><%=h person.last_name %></td> > > However I would like in the index view to add links to show or > destroy and in the show view add an edit link. > > I tried to use the new layout for partials feature > > <%= render :partial => @people, :layout => ''index''%> > <%= render :partial => @people, :layout => ''show''%> > > where the _index.html.erb contained the show and destroy links and the > _show.html.erb contains the edit link. However for the layout it only > seems to be rendered once for a collection not once for each object in > the collection. Am I doing something wrong or is there a neat way > round this. > > Thanks > > Anthony--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---