Hi all, just started using rails, the answer to this question might seem obvious to others, but unfortunately not to me. I am trying to create a grid of results using a collection and a partial. but instead of using the <ul> tag or the table format, i am going to use css. That''s whay i need to pass an incremental variable to each returned result that could calculate its position within the grid. Is there a way to retreive the row # within the partial the same way i could get the index value in a for loop? Thanks in advance for any help --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
ngumamonene wrote:> just started using rails, the answer to this question might seem > obvious to others, but unfortunately not to me. > I am trying to create a grid of results using a collection and a > partial. > > but instead of using the <ul> tag or the table format, i am going to > use css. > That''s whay i need to pass an incremental variable to each returned > result that could calculate its position within the grid. > Is there a way to retreive the row # within the partial the same way i > could get the index value in a for loop?When you retrieve several model objects (e.g. @people Person.find(:all)), that variable is just an ordinary array. So each Person object in the array has an associated index, starting at 0. If you render a partial using a collection like this: render(:partial => ''person'', :collection => @people), Rails creates a local variable called ''person_counter'' which contains the index number of the current object. (It''s named after the name of the partial, not the collection, so if your partial is called ''bob'' then you''ll have to use ''bob_counter''.) Chris --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
ngumamonene wrote:> Hi all, > just started using rails, the answer to this question might seem > obvious to others, but unfortunately not to me. > I am trying to create a grid of results using a collection and a > partial. > > but instead of using the <ul> tag or the table format, i am going to > use css. > That''s whay i need to pass an incremental variable to each returned > result that could calculate its position within the grid. > Is there a way to retreive the row # within the partial the same way i > could get the index value in a for loop?By the way, this kind of query should go in the main RoR:Talk group, rather than the RoR:Spinoffs group, which is for talk related to Scriptaculous, etc. Chris --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Thanks Chris, thanks rails It couldn''t be simpler than that. Apologies for the miscategorizing --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---