Hi there, I have Ajax Pagination (sort of) working on my Ruby on Rails Project. However my problem is, is that it repeats each page x number of times, x being equal to the amount of records I have on each page. So lets say for example prior to the Ajax Pagination, I had 12 records per page, now I have each record on that page replicated 12 times. I render a partial as follows. <table width="500" border="1" align="center" class="gridtable" id="meh"> <tr id="table2"> <th height="26" scope="col">Username</th> <th scope="col">Date Leaving</th> <th scope="col">Date Submitted</th> <th scope="col">Approved</th> <th scope="col">Date Updated</th> </tr> <% div_for for holidays in @holidays%> <tr> <td><%= link_to holiday.user.username, holiday %></td> <td><%= holiday.dateleaving%></td> <td><%= time_ago_in_words(holiday.created_at) %></td> <td><%= holiday.approved%></td> <td><%= time_ago_in_words(holiday.updated_at) %></td> </tr> <% end %> </table> Any ideas? -- 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.
On 7 April 2012 20:07, Antony Shimmin <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi there, > > I have Ajax Pagination (sort of) working on my Ruby on Rails Project. > > However my problem is, is that it repeats each page x number of times, x > being equal to the amount of records I have on each page. > > So lets say for example prior to the Ajax Pagination, I had 12 records > per page, now I have each record on that page replicated 12 times. > > I render a partial as follows. > > <table width="500" border="1" align="center" class="gridtable" id="meh"> > <tr id="table2"> > > <th height="26" scope="col">Username</th> > <th scope="col">Date Leaving</th> > <th scope="col">Date Submitted</th> > <th scope="col">Approved</th> > <th scope="col">Date Updated</th> > </tr> > <% div_for for holidays in @holidays%>That should be "for holiday in" not "for holidays in" Have a look at the Rails Guide on Debugging, it will show you how to debug code so you can work out such problems yourself. Colin> <tr> > <td><%= link_to holiday.user.username, holiday %></td> > <td><%= holiday.dateleaving%></td> > <td><%= time_ago_in_words(holiday.created_at) %></td> > <td><%= holiday.approved%></td> > <td><%= time_ago_in_words(holiday.updated_at) %></td> > </tr> > <% end %> > </table> > > Any ideas? > > -- > 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. >-- gplus.to/clanlaw -- 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 7 April 2012 20:47, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 7 April 2012 20:07, Antony Shimmin <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> Hi there, >> >> I have Ajax Pagination (sort of) working on my Ruby on Rails Project. >> >> However my problem is, is that it repeats each page x number of times, x >> being equal to the amount of records I have on each page. >> >> So lets say for example prior to the Ajax Pagination, I had 12 records >> per page, now I have each record on that page replicated 12 times. >> >> I render a partial as follows. >> >> <table width="500" border="1" align="center" class="gridtable" id="meh"> >> <tr id="table2"> >> >> <th height="26" scope="col">Username</th> >> <th scope="col">Date Leaving</th> >> <th scope="col">Date Submitted</th> >> <th scope="col">Approved</th> >> <th scope="col">Date Updated</th> >> </tr> >> <% div_for for holidays in @holidays%> > > That should be "for holiday in" not "for holidays in" > > Have a look at the Rails Guide on Debugging, it will show you how to > debug code so you can work out such problems yourself.But even then I am not convinced it will work. What is the div_for doing there? Since you have not got "<%= div_for" the div_for will not actually produce any code. I think more likely you want something like <% @holidays.each do |holiday| %> <%= div_for holiday do %> Colin> > > Colin > >> <tr> >> <td><%= link_to holiday.user.username, holiday %></td> >> <td><%= holiday.dateleaving%></td> >> <td><%= time_ago_in_words(holiday.created_at) %></td> >> <td><%= holiday.approved%></td> >> <td><%= time_ago_in_words(holiday.updated_at) %></td> >> </tr> >> <% end %> >> </table> >> >> Any ideas? >> >> -- >> 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. >> > > > > -- > gplus.to/clanlaw-- gplus.to/clanlaw -- 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.
Changed that, still doesn''t work. Will have a look at the debugger. Thank you Colin Law wrote in post #1055435:> On 7 April 2012 20:07, Antony Shimmin <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> I render a partial as follows. >> <% div_for for holidays in @holidays%> > That should be "for holiday in" not "for holidays in" > > Have a look at the Rails Guide on Debugging, it will show you how to > debug code so you can work out such problems yourself. > > > Colin > >> Any ideas? >> >> -- >> 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. >> > > > > -- > gplus.to/clanlaw-- 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.
Right that''s worked, however it now puts the column headings above each record? -- 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.
On 7 April 2012 21:25, sherpa derpa <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Right that''s worked, however it now puts the column headings above each > record?What has worked? Since you have not quoted any previous reply no-one knows what you are referring to. First work out what html you want then write to code to generate that html. If you don''t know what html you want this is not really the right place to ask as that is nothing to do with Rails. If you know the html you want but the code is not generating the html you want then you can ask here. 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.
Apologies. You''re code has worked. 12 Records now show up. However the column headings appear above each record, instead of just at the top. <table width="500" border="1" align="center" class="gridtable" id="meh"> <tr id="table2"> <th height="26" scope="col">Username</th> <th scope="col">Date Leaving</th> <th scope="col">Date Submitted</th> <th scope="col">Approved</th> <th scope="col">Date Updated</th> </tr> <tr> <% div_for holiday do %> <td><%= link_to holiday.user.username, holiday %></td> <td><%= holiday.dateleaving%></td> <td><%= time_ago_in_words(holiday.created_at) %></td> <td><%= holiday.approved%></td> <td><%= time_ago_in_words(holiday.updated_at) %></td> </tr> </table> <% end %> -- 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.
On 7 April 2012 21:38, sherpa derpa <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Apologies. > > You''re code has worked. 12 Records now show up. However the column > headings appear above each record, instead of just at the top.Once again you have not quoted the previous reply so we don''t know which message you are referring to.> > <table width="500" border="1" align="center" class="gridtable" id="meh"> > <tr id="table2"> > <th height="26" scope="col">Username</th> > <th scope="col">Date Leaving</th> > <th scope="col">Date Submitted</th> > <th scope="col">Approved</th> > <th scope="col">Date Updated</th> > </tr> > <tr> > <% div_for holiday do %> > <td><%= link_to holiday.user.username, holiday %></td> > <td><%= holiday.dateleaving%></td> > <td><%= time_ago_in_words(holiday.created_at) %></td> > <td><%= holiday.approved%></td> > <td><%= time_ago_in_words(holiday.updated_at) %></td> > </tr> > </table> > <% end %>That code only seems to show one record. I don''t see any loop in it. 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.
The code <%= div_for holiday do %> What i have is each individual record now having the column headings above the record, when it should be on top of every page just once? Colin Law wrote in post #1055437:> On 7 April 2012 20:47, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >>> >>> </tr> >>> <% div_for for holidays in @holidays%> >> >> That should be "for holiday in" not "for holidays in" >> >> Have a look at the Rails Guide on Debugging, it will show you how to >> debug code so you can work out such problems yourself. > > But even then I am not convinced it will work. What is the div_for > doing there? Since you have not got "<%= div_for" the div_for will > not actually produce any code. I think more likely you want something > like > <% @holidays.each do |holiday| %> > <%= div_for holiday do %> > > Colin > >>> </tr> >>> 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. >>> >> >> >> >> -- >> gplus.to/clanlaw > > > > -- > gplus.to/clanlaw-- 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.
On 7 April 2012 21:49, sherpa derpa <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> The code > > <%= div_for holiday do %>Apart from the fact that there is no loop in the code, is it legal html to have td tags inside a div? Even if it is I can''t think of any good reason for it. 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.
Thank you for your help Colin. I think I know what I need to do. Colin Law wrote in post #1055448:> On 7 April 2012 21:49, sherpa derpa <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> The code >> >> <%= div_for holiday do %> > > Apart from the fact that there is no loop in the code, is it legal > html to have td tags inside a div? Even if it is I can''t think of any > good reason for it. > > Colin-- 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.