Hi, Does anyone how to automatically put sequence number in view? I have an inquiry form like below. However, the number of questions is more than 70, and they are deleted and/reordered in the future. So, I do not want to hard code the number. I was trying to create variable and increment on each question, but everything are displayed as 1. I would appreciate if you could tell me any good way to manage this. Thanks, Glenn <%= start_form_tag :action => ''update'' %> <% Integer @number = 0%> <div class="row"> <strong><%=h @number.next%>.</strong> ID Number: <%=text_field ''person'', ''id_number'' %> </div> <div class="row"> <strong><%=h @number.next%>.</strong> Name: <%=text_field ''person'', ''name'' %> </div> <div class="row"> <strong><%=h number.next%>.</strong> Email: <%=text_field ''person'', ''email'' %> </div> ...lots of fields... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hey Change .next to @number += 1 and it will work Cheers, Yuri On 5/10/07, Glenn <withhawaii-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, > > Does anyone how to automatically put sequence number in view? > > I have an inquiry form like below. However, the number of questions > is more than 70, and they are deleted and/reordered in the future. > So, I do not want to hard code the number. I was trying to create > variable and increment on each question, but everything are displayed > as 1. > > I would appreciate if you could tell me any good way to manage this. > > Thanks, > Glenn > > > <%= start_form_tag :action => ''update'' %> > <% Integer @number = 0%> > <div class="row"> > <strong><%=h @number.next%>.</strong> ID Number: > <%=text_field ''person'', ''id_number'' %> > </div> > > <div class="row"> > <strong><%=h @number.next%>.</strong> Name: > <%=text_field ''person'', ''name'' %> > </div> > > <div class="row"> > <strong><%=h number.next%>.</strong> Email: > <%=text_field ''person'', ''email'' %> > </div> > > ...lots of fields... > > > > >-- Best regards, Yuri Leikind --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> Change .next to> @number += 1 As a side note, if you use the fixture_references plugin http://agilewebdevelopment.com/plugins/fixture_references , you can even use that trick in fixtures : file: people.yml <% @id=0 %> john: name: John id: <%= @id+=1 %> bill name: Bill id: <%= @id+=1 %> Alain ---- blog.ravet.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 -~----------~----~----~----~------~----~------~--~---
Thank you so much Yuri and Alain! It worked fine, and it''s good to know I can use this for fixtures. Glenn --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---