# Strange pagination bug in 1.1.6

**URL:** <https://www.ruby-forum.com/t/strange-pagination-bug-in-1-1-6/67532>\
**Category:** Rails\
**Created:** [September 5, 2006, 1:46am UTC](https://www.ruby-forum.com/t/strange-pagination-bug-in-1-1-6/67532 "2006-09-05T01:46:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![spike](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8797f3/32.png) [@spike](https://www.ruby-forum.com/u/spike)\
**Post date:** [September 5, 2006, 1:46am UTC](https://www.ruby-forum.com/t/strange-pagination-bug-in-1-1-6/67532/1 "2006-09-05T01:46:40Z")

</div>

Hi there, I’ve recently upgraded to 1.1.6 and noticed this has started  
happening. It’s a standard list page:

Controller:  
def list  
@artwork\_pages = Paginator.new self, Artwork.count, 10,  
@params[‘page’]  
@artworks = Artwork.find :all,  
:conditions =\> [ “artist\_id = ?”,  
params[:artist] ],  
:limit =\> @artwork\_pages.items\_per\_page,  
:offset =\> @artwork\_pages.current.offset  
@artist = Artist.find(params[:artist])  
end

View:

# Artworks

\<%= link\_to 'Back to Artist', :controller =\> '/admin/artist', :action =\> 'show', :id =\> params[:artist] %\> | \<%= link\_to 'Manage Categories', :controller =\> '/admin/category', :action =\> 'list', :artist =\> @artist %\>

Below are the artworks that belong to \<%= h @artist.name %\>. From here you can create a new artwork and work with existing artworks. Once you have created \<%= link\_to 'Categories', :controller =\> '/admin/category', :action =\> 'list', :artist =\> @artist %\> you can begin adding artworks to them by going to the \<%= link\_to 'Categories', :controller =\> '/admin/category', :action =\> 'list', :artist =\> @artist %\> section and clicking on the category's name.

\<%= link\_to 'Create a New Artwork', :action =\> 'new' %\>

\<% if @artworks.empty? %\>

There are currently no Artworks...

\<% else %\>

```
<th>Name</th>
<th>Price</th>
<th>Sold?</th>
<th colspan="2">Options</th>

```

\<% for artwork in @artworks %\>

\<% end %\>

|
| |
| \<%= link\_to (h artwork.name), :action =\> 'show', :id =\> artwork %\> | $\<%=h "%.2f" % artwork.price %\> | \<% if artwork.sale\_status == true %\>Yes\<% else %\>No\<% end %\> | \<%= link\_to 'Edit', :action =\> 'edit', :id =\> artwork %\> | \<%= link\_to 'Destroy', :action =\> 'confirm', :id =\> artwork %\> |

\<% end %\>

\<%= link\_to 'Previous page', { :page =\> @artwork\_pages.current.previous } if @artwork\_pages.current.previous %\> \<%= link\_to 'Next page', { :page =\> @artwork\_pages.current.next } if @artwork\_pages.current.next %\>

* * *

Now the problem is that even though there aren’t 10 artworks, the ‘Next  
page’ shows up anyway. I’ve compared this CV set to another CV set that  
basically does exactly the same thing except with categories, and it  
doesn’t have the same problem. Even in the logs, everything is exactly  
the same. It’s as if @artwork\_pages.current.next is falsely triggering?

There are more than 10 artworks over ALL artists, perhaps it’s  
triggering because of that. Is that an error in my code then that’s  
counting all artworks instead of only this artists artworks, or is it a  
bug?

Cheers,

Brendon

---

<div class="post-metadata">

**Author:** ![spike](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8797f3/32.png) [@spike](https://www.ruby-forum.com/u/spike)\
**Post date:** [September 5, 2006, 1:58am UTC](https://www.ruby-forum.com/t/strange-pagination-bug-in-1-1-6/67532/2 "2006-09-05T01:58:36Z")

</div>

My Bad, here’s the error:

```
@artwork_pages = Paginator.new self, Artwork.count(:conditions => [ 

```

“artist\_id = ?”, params[:artist] ]), 10, @params[‘page’]

Needed to include the condition in the count also 🙂 duh!

Cheers,

Brendon
