Pagination with customer list.rhtml

(To preface this - you can just imagine I am making the cookbook from
the Rolling with Ruby on Rails tutorial)

I have made a customer list view (list.rhtml), so that I could include
attributes from multiple database tables. This works fine, however, the
list page no longer paginates (i.e. does limit the item list to 10 items
at a time, with a 1, 2, 3… links at the bottom)

I am trying to break through my newbie shell, but still am a newbie
here. I was wondering if someone could help me with determining the
code that I need to add, and whether it needs to be added to the
controller or the customer list.rhtml.

Thanks in advance…

Sorry guys. I meant CUSTOM, not customer. One of the Fruedian slips…

So of course my buddy just found the answer out so I am including it:

I have a ticket tracking system, and my main table is tickets, so I
think you can figure this out

In your controller (Mine is a ticket_controller.rb)

add the following under def list

@ticket_pages, @tickets =
paginate :ticket, :order_by => “id”, :per_page => 20

This will enable pagination in the list view. However, you still won’t
have the 1, 2, 3… links at the bottom. The below outline resolves
this.

In you list view (Mine is list.rhtml), place the following code in the
body somewhere:

<%= pagination_links (@ticket_pages) %>

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs