Ajax Pagination, repeating

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?

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

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

Changed that, still doesn't work.

Will have a look at the debugger.

Thank you

Colin Law wrote in post #1055435:

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

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 %>

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

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:

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

Thank you for your help Colin.

I think I know what I need to do.

Colin Law wrote in post #1055448: