Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #3059 (closed defect: fixed)

Opened 4 years ago

Last modified 3 years ago

Pagination not working in SQL Server

Reported by: rdifrango@captechentures.com Assigned to: tomafro
Priority: high Milestone:
Component: ActiveRecord Version: 0.14.3
Severity: normal Keywords: sqlserver
Cc: rdifrango@captechventures.com

Description

The pagination is not working properly with rails: I have the following listing page:

<h1>Listing Tim User</h1>

<table>

<tr>

<th>Username</th>

<th>Firstname</th> <th>Lastname</th> <th>Is Admin</th> <th>Is Construction</th> <th>Is Sales</th> <th>All Reports Access</th> <th>Selection unlock</th> <th>Show</th> <th>Edit</th> <th>Destroy</th>

</tr>

<% for tim_user in @tim_users %>

<tr>

<td><%= tim_user.username %></td>

<td><%= tim_user.firstname %></td> <td><%= tim_user.lastname %></td> <td><%= tim_user.isadmin %></td> <td><%= tim_user.isconstruction %></td> <td><%= tim_user.is_sales %></td> <td><%= tim_user.all_reports_access %></td> <td><%= tim_user.selection_unlock %></td>

<td><%= link_to 'Show', :action => 'show', :id => tim_user %></td> <td><%= link_to 'Edit', :action => 'edit', :id => tim_user %></td> <td><%= link_to 'Destroy', {:action => 'destroy', :id => tim_user}, :confirm => 'Are you sure?' %></td>

</tr>

<% end %> </table>

<%= link_to 'Previous page', { :page => @tim_user_pages.current.previous } if @tim_user_pages.current.previous %> <%= link_to 'Next page', { :page => @tim_user_pages.current.next } if @tim_user_pages.current.next %>

<br />

<%= link_to 'New tim_user', :action => 'new' %>

And when I click the next button the same group appears for all pages.

Change History

12/01/05 06:40:44 changed by rdifrango@captechventures.com

Seems as though it works okay if you add the following to the listing method in the controller:

, :order_by=>"id ASC"

The only problem with this is that if you override the primary_key column then you are DOA.

In the previous version, David Chilton had requested this patch which works most of the time:

options[:order] = "#{get_identity_column(get_table_name(sql))} ASC"

The only downside to this solution is once again, it does not work if the primary key column is over ridden. Any hope of getting access to the primary key column in the ConnectionAdapters?

12/01/05 13:48:56 changed by anonymous

  • cc set to rdifrango@captechventures.com.

04/25/06 00:59:57 changed by anonymous

Just to note, this problem still exists (using Rails 1.1). The :order_by=>"id ASC" fix works, though.

08/24/06 18:59:49 changed by anonymous

  • keywords set to sqlserver.
  • owner changed from David to tom@popdog.net.

09/19/06 10:31:35 changed by tomafro

  • owner changed from tom@popdog.net to tomafro.

09/21/06 11:03:12 changed by tomafro

  • status changed from new to closed.
  • resolution set to fixed.

This will be fixed by #6254