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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Colin Law at Apr 7, 2012 at 7:48 pm

    On 7 April 2012 20:07, Antony Shimmin 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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Colin Law at Apr 7, 2012 at 7:57 pm

    On 7 April 2012 20:47, Colin Law wrote:
    On 7 April 2012 20:07, Antony Shimmin 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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Sherpa derpa at Apr 7, 2012 at 8:25 pm
    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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Colin Law at Apr 7, 2012 at 8:34 pm

    On 7 April 2012 21:25, sherpa derpa 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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Sherpa derpa at Apr 7, 2012 at 8:49 pm
    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 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@googlegroups.com.
    To unsubscribe from this group, send email to
    rubyonrails-talk+unsubscribe@googlegroups.com.
    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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Colin Law at Apr 7, 2012 at 8:54 pm

    On 7 April 2012 21:49, sherpa derpa 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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Sherpa derpa at Apr 7, 2012 at 8:59 pm
    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 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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Sherpa derpa at Apr 7, 2012 at 8:00 pm
    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 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@googlegroups.com.
    To unsubscribe from this group, send email to
    rubyonrails-talk+unsubscribe@googlegroups.com.
    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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Sherpa derpa at Apr 7, 2012 at 8:38 pm
    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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Colin Law at Apr 7, 2012 at 8:44 pm

    On 7 April 2012 21:38, sherpa derpa 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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedApr 7, '12 at 7:07p
activeApr 7, '12 at 8:59p
posts11
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Sherpa derpa: 6 posts Colin Law: 5 posts

People

Translate

site design / logo © 2022 Grokbase