Abnormal Pagination Using SQL Server


#1

I’m using RoR 1.0, Windows 2000, and SQL Server 2000. I am connecting to
the database using these directions:
http://wiki.rubyonrails.com/rails/pages/HowtoConnectToMicrosoftSQLServer.

Using the scaffold generator to generate the default files (ruby
script/generate scaffold Location) I start up WebBrick and pull up the
page. There are 58 records in the table. I am given the first 10
records. No problem so far. Then I click the next page link - which
points to page 2 (page=2). I am presented with the same 10 records with
the same ten links. This continues for three more “next page” clicks for
a total of fifty. Then the really confusing part… on the the fifth
click I am only given eight of the same records.

In other words, Rails seems to know how many records there are but only
seems to be able to display the first 10 (or however many per page it’s
set for). All other functions (edit, new, show, etc) appear to work
correctly.

Any help would be appreciated.

  • Eric

#2

Eric,

I have had that problem as well. I thought I submitted a Ticket on this
one and it is the following:

http://dev.rubyonrails.org/ticket/3059

The only way to get around this is to override the default scaffold
[which most would tell you to do any way], and add the following to your
list method:

def list
@exterior_selection_pages, @exterior_selections = paginate
:exterior_selections, :per_page => 20, :order_by=>“id ASC”
end

Obviously substitute your object name for mine and your ID field as
well. I would submit another ticket on this as this only seems to
affect SQL Server.

Just curious do you have an ID column or did you override it?

Ron


From: removed_email_address@domain.invalid on behalf of Eric R.
Sent: Thu 12/22/2005 7:14 PM
To: removed_email_address@domain.invalid
Subject: [Rails] Abnormal Pagination Using SQL Server

I’m using RoR 1.0, Windows 2000, and SQL Server 2000. I am connecting to
the database using these directions:
http://wiki.rubyonrails.com/rails/pages/HowtoConnectToMicrosoftSQLServer.

Using the scaffold generator to generate the default files (ruby
script/generate scaffold Location) I start up WebBrick and pull up the
page. There are 58 records in the table. I am given the first 10
records. No problem so far. Then I click the next page link - which
points to page 2 (page=2). I am presented with the same 10 records with
the same ten links. This continues for three more “next page” clicks for
a total of fifty. Then the really confusing part… on the the fifth
click I am only given eight of the same records.

In other words, Rails seems to know how many records there are but only
seems to be able to display the first 10 (or however many per page it’s
set for). All other functions (edit, new, show, etc) appear to work
correctly.

Any help would be appreciated.

  • Eric


Posted via http://www.ruby-forum.com/.


Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails


#3

Ron - thanks. That did the trick. I’m glad to know I’m not the only one
with this issue. Oh, and I am using an “id” column.

  • Eric