I have a couple different partials for members, to which each have names that somewhat describe what the partial is: ex member_pic <%= render :partial => "admin/members/member_pic", :collection => @members %> Which shows the members pic along with their details. I don''t like the way that to make reference to a single member within the @members collection inside the partial I have to use the partial name, ex member_pic.full_name. I have other cases where it can be confusing. I figure there must be a way around this, since this Rails :), but I haven''t been able to find out how. ...if you are just rendering a single object you could probably pass it in through the locals, but there must be a better way. Thanks -- 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 -~----------~----~----~----~------~----~------~--~---
Store the reference name as a variable and just do: <%= render :partial => custom_var %> On Dec 18, 2007 9:20 AM, Chris Olsen <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I have a couple different partials for members, to which each have names > that somewhat describe what the partial is: > > ex member_pic > <%= render :partial => "admin/members/member_pic", :collection => > @members %> > > Which shows the members pic along with their details. > > I don''t like the way that to make reference to a single member within > the @members collection inside the partial I have to use the partial > name, ex member_pic.full_name. I have other cases where it can be > confusing. > > I figure there must be a way around this, since this Rails :), but I > haven''t been able to find out how. > > ...if you are just rendering a single object you could probably pass it > in through the locals, but there must be a better way. > > Thanks > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ryan Bigg wrote:> Store the reference name as a variable and just do: > > <%= render :partial => custom_var %> > > On Dec 18, 2007 9:20 AM, Chris Olsen <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: >I am note sure how that will change the reference to the object/collection within the partial? I know if you have a _member.html.erb partial you can do like you mentioned: <%= render :partial => @member %> but that then calls on the _member.html.erb partial. In my case I have a partial called _member_pic.html.erb, but I have a variable of @members that is to be passed into it. I could instead create a collection called @member_pics, but that would lead to further confusion and wouldn''t change how the reference is made within the partial file. Or at least I think :), if not please give me some more details to what you meant. Thanks. -- 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 -~----------~----~----~----~------~----~------~--~---
I think we''re both confused. What are you trying to do again? Could you elaborate? On Dec 18, 2007 9:35 AM, Chris Olsen <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Ryan Bigg wrote: > > Store the reference name as a variable and just do: > > > > <%= render :partial => custom_var %> > > > > On Dec 18, 2007 9:20 AM, Chris Olsen <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > wrote: > > > > I am note sure how that will change the reference to the > object/collection within the partial? > > I know if you have a _member.html.erb partial you can do like you > mentioned: > <%= render :partial => @member %> > > but that then calls on the _member.html.erb partial. > > In my case I have a partial called _member_pic.html.erb, but I have a > variable of @members that is to be passed into it. I could instead > create a collection called @member_pics, but that would lead to further > confusion and wouldn''t change how the reference is made within the > partial file. > > Or at least I think :), if not please give me some more details to what > you meant. > > Thanks. > > > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
:) I guess I didn''t make it very clear. The issue that I have is a making reference the object/collection within the partial ex. ##_member_pic.html <table id="member-<%= member_pic.id %>" class="member_photo"> <tr><td><%= image_tag member_pic.photo.public_filename(:thumb) %></td></tr> <tr><td><%= member_pic.full_name %></td></tr> <tr><td><%= mail_to member_pic.email %></td></tr> <tr><td><%= member_pic.phone_number %></td></tr> <tr><td><%= link_to "Remove", admin_group_member_url(group, member_pic.group_members.first.id), :method => :delete %></td></tr> </table> <%= render :partial => "admin/members/member_pic", :collection => @members, :locals => {:group => @group} %> As you can see I have to call member_pic.full_name within the partial seeing as that is the name of the partial. The reason for this name is that I have 3 different partials for a member. I was just wondering if there is a way to better control the reference that is used within the partial. Thanks for the help. BTW the table is needed :) -- 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 -~----------~----~----~----~------~----~------~--~---
Oh I see what you mean, I think. You want to see the local name that''s used for the collection? You can''t do this. Also you''re passing in an instance variable as a local, why? The instance will be available in the partial. On Dec 18, 2007 10:50 AM, Chris Olsen <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > :) I guess I didn''t make it very clear. The issue that I have is a > making reference the object/collection within the partial ex. > > ##_member_pic.html > <table id="member-<%= member_pic.id %>" class="member_photo"> > <tr><td><%= image_tag member_pic.photo.public_filename(:thumb) > %></td></tr> > <tr><td><%= member_pic.full_name %></td></tr> > <tr><td><%= mail_to member_pic.email %></td></tr> > <tr><td><%= member_pic.phone_number %></td></tr> > <tr><td><%= link_to "Remove", admin_group_member_url(group, > member_pic.group_members.first.id), > :method => :delete %></td></tr> > </table> > > <%= render :partial => "admin/members/member_pic", :collection => > @members, :locals => {:group => @group} %> > > As you can see I have to call member_pic.full_name within the partial > seeing as that is the name of the partial. The reason for this name is > that I have 3 different partials for a member. > > I was just wondering if there is a way to better control the reference > that is used within the partial. > > Thanks for the help. > > BTW the table is needed :) > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ryan Bigg wrote:> Oh I see what you mean, I think. You want to see the local name that''s > used > for the collection? You can''t do this.That is sad to hear> Also you''re passing in an instance variable as a local, why? The > instance > will be available in the partial.Oh really? :) I have always done it that way. That will save me some typing. Thanks for the help. -- 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 -~----------~----~----~----~------~----~------~--~---