Forum: Ruby on Rails List shows always first page

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Sam K. (Guest)
on 2006-04-26 22:16
Hello!

I'm a beginner of rails.
I made a simple test project with rails 1.1.2 and ruby 1.8.2 on Windows
XP.
DB is SQLServer 7.0.
I'm connecting the server thru ODBC.

I created a table named "users" with about 10 columns.
I inserted 1000 sample records.

I created a scaffold for user model and login controller for it using
the script.
Everything's fine except that the pagination.
Be default the list shows 10 records per page.
I clicked "Next Page" and the page refreshed but the data is still same
as the first page.
The URL shows page=2 parameter.
I opened the controller code and found the following code.

  def list
    @user_pages, @users = paginate :users, :per_page => 10
  end

I changed 10 to 100 and the page showed 100 records but still the 2nd
page showed the 1st page.

Did I miss something?
Or should I add code to make the pagination work?

Thanks.
Sam
Sam K. (Guest)
on 2006-04-26 22:33
Sam K. wrote:
> Hello!
>
> I'm a beginner of rails.
> I made a simple test project with rails 1.1.2 and ruby 1.8.2 on Windows
> XP.
> DB is SQLServer 7.0.
> I'm connecting the server thru ODBC.
>
> I created a table named "users" with about 10 columns.
> I inserted 1000 sample records.
>
> I created a scaffold for user model and login controller for it using
> the script.
> Everything's fine except that the pagination.
> Be default the list shows 10 records per page.
> I clicked "Next Page" and the page refreshed but the data is still same
> as the first page.
> The URL shows page=2 parameter.
> I opened the controller code and found the following code.
>
>   def list
>     @user_pages, @users = paginate :users, :per_page => 10
>   end
>
> I changed 10 to 100 and the page showed 100 records but still the 2nd
> page showed the 1st page.
>
> Did I miss something?
> Or should I add code to make the pagination work?
>
> Thanks.
> Sam


Oh, I figured that out.
I need to set :order option.
After setting it, it worked.
This topic is locked and can not be replied to.