I''m trying to render a list of div''s with ids "item1", "item2", "item3", etc.. Trying to do it like this: <% for i in 0...-g61OF5+O77XIRFoCfZT8TA@public.gmane.org %> <div id="item<%= i %>" > .. blah blah .. </div> <% end %> Pretty sure the syntax is wrong. I couldn''t find the answer after googling for a bit - perhaps I''m too new and dont know where to look. Help please? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
<% @items.each do |item| %> <div class="item<%= item.id %>"> <%= item.record-name %> </div> <% end %> I think it goes model.method action |table| tuple.relvar. I took the logic from here http://guides.rails.info/getting_started.html#rest <http://guides.rails.info/getting_started.html#rest>and applied the solution for post to your problem. I''m a newbian refuge as well. On Thu, Jul 29, 2010 at 5:40 PM, Eddie Du <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I''m trying to render a list of div''s with ids "item1", "item2", "item3", > etc.. > Trying to do it like this: > > <% for i in 0...-g61OF5+O77XIRFoCfZT8TA@public.gmane.org %> > > <div id="item<%= i %>" > > .. blah blah .. > </div> > > <% end %> > > Pretty sure the syntax is wrong. I couldn''t find the answer after > googling for a bit - perhaps I''m too new and dont know where to look. > > Help please? > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 30 July 2010 01:40, Eddie Du <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I''m trying to render a list of div''s with ids "item1", "item2", "item3", > etc.. > Trying to do it like this: > > <% for i in 0...-g61OF5+O77XIRFoCfZT8TA@public.gmane.org %> > > <div id="item<%= i %>" > > .. blah blah .. > </div> > > <% end %> > > Pretty sure the syntax is wrong. I couldn''t find the answer after > googling for a bit - perhaps I''m too new and dont know where to look.What is the problem that you see? Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 30 July 2010 03:48, Angel Robert Marquez <angel.marquez-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> <% @items.each do |item| %> <div class="item<%= item.id %>"> > <%= item.record-name %> > </div> <% end %>>> I''m trying to render a list of div''s with ids "item1", "item2", "item3",If you''re specifically after "item1" rather than "item<item.id>", then you can use "each_with_index": <% @items.each_with_index do |item, index| %> <div class="item<%= index+1 %>"> <%= item.record-name %> </div> <% end %> -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I realized I just typed the quotes wrong. Sorry! Though thanks for the replies, especially @angel and @Michael Pavling, those are really helpful suggestions. :) -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.