# Two, independant paginations on one page

**URL:** <https://www.ruby-forum.com/t/two-independant-paginations-on-one-page/118578>\
**Category:** Rails\
**Created:** [October 29, 2007, 5:14am UTC](https://www.ruby-forum.com/t/two-independant-paginations-on-one-page/118578 "2007-10-29T05:14:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cwt137](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/7c8e57/32.png) [@cwt137](https://www.ruby-forum.com/u/cwt137)\
**Post date:** [October 29, 2007, 5:14am UTC](https://www.ruby-forum.com/t/two-independant-paginations-on-one-page/118578/1 "2007-10-29T05:14:05Z")

</div>

I am a college student and just getting into the rails world. So please  
excuse me if the answer is simple… but I have RTFM and searched google  
many times to no avail.

Alright I am making a simple blog like site. The site has two columns of  
content: stories and comic(images). Now I want each to have a pagination  
so you can click more\_stories and it displays more stories but leaves  
the comics unchanged. Same if they hit “more\_comics”.

I stated with the default pagination but quickly abandoned it in favor  
of will\_paginate. The old pagination would advance both if you clicked  
either more.

It seems that will\_paginate should work as you can feed it the page  
number you want it to be on, but i have yet to get it to work.

I use a link\_to that just calls index and says if it was the story or  
image more that was clicked and if it was up or down.

def index

```
if @stories.nil?
  @p_image=1
  @p_story= 1
   @stories = Story.paginate :page => @p_story
   @images = Image.paginate :page => @p_image
end

if params[:type] == "story"

   if params[:call] == "up"
      @p_story = @p_story + 1
    end

  if params[:call] == "down"
        @p_story = @p_story - 1
  end

  @p_image = params[:iv]
  @stories = Story.paginate :page => @p_story
end

if params[:type] == "image"

    if params[:call] == "up"
      @p_image = @p_image + 1
    end

  if params[:call] == "down"
        @p_image = @p_image - 1
  end

    @p_story = params[:sv]
    @images = Image.paginate :page => @p_image
end

```

end

Now i am clearly missing something as it wont go past a value of 2. and  
still resets when I switch between them.

thank you in advance.

---

<div class="post-metadata">

**Author:** ![cwt137](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/7c8e57/32.png) [@cwt137](https://www.ruby-forum.com/u/cwt137)\
**Post date:** [October 29, 2007, 7:51am UTC](https://www.ruby-forum.com/t/two-independant-paginations-on-one-page/118578/2 "2007-10-29T07:51:43Z")

</div>

Uh, @stories is going to be nil everytime - HTTP is stateless,  
@stories is an instance variable the gets set every time the  
controller is called. Why aren’t you just paginating directly from  
the page number, and then just using -1/+1 values of the current page  
for your links in the view?

On Oct 28, 9:14 pm, Chris T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
