# Pagination in single public page

**URL:** <https://www.ruby-forum.com/t/pagination-in-single-public-page/137468>\
**Category:** Rails\
**Created:** [May 13, 2008, 1:34pm UTC](https://www.ruby-forum.com/t/pagination-in-single-public-page/137468 "2008-05-13T13:34:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaizerkaizer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/45deac/32.png) [@kaizerkaizer](https://www.ruby-forum.com/u/kaizerkaizer)\
**Post date:** [May 13, 2008, 1:34pm UTC](https://www.ruby-forum.com/t/pagination-in-single-public-page/137468/1 "2008-05-13T13:34:30Z")

</div>

I’m trying to show my blog to another logged in user, the blog is  
paginated and only present on one page (where everything else is  
presented about that specific user).

My problem is that the paginate functio does not check for the next page  
of blog posts for that user, instead it links me back to my own  
blog-page (preentation index). There the paginate function works, for  
example it finds my own blogs on page 2. If I try to read my own blog in  
my public page (show) it links me back to my own page (index) again.

The page 2 link shows “/presentation?page=2”, which looks a bit odd, I  
thought it should look something like:  
“/presentation?login=d.stensson40%currant.se?page=2” since it’s a  
specific user with the address:  
“/presentation?login=d.stensson40%currant.se” .

Clicking the link to page=2 I get re-routed to “/pres” (index page)

I’m having a hard time wrapping this around my head, what am I doing so  
horribly wrong?

#########################################################  
Application controller ##################################  
#########################################################

def make\_presentation\_vars  
@pages, @posts = paginate(@blog.posts, :per\_page =\> 2)  
end

#########################################################  
class PresentationController \< ApplicationController ####  
#########################################################

def show  
@hide\_edit\_links = true  
login = params[:login]  
@user = User.find\_by\_login(login)

```
@logged_in_user = User.find(session[:user]) if logged_in?
if @user
  @blog = @user.blog ||= Blog.new #fulkod
make_presentation_vars
end

```

end

#########################################################  
Presentation/show #######################################  
(partial)\_blog ##########################################  
#########################################################

\<% if paginated? %\> \<% first = @pages.current\_page.first\_item %\> \<% last = @pages.current\_page.last\_item %\> \<% if first == last %\> Post \<%= last %\> of \<% else %\> Posts \<%= first %\>–\<%= last %\> of \<% end %\> \<% end %\> \<%= pluralize(@blog.posts.count, "blog post") %\>

\<%= render :partial =\> “posts/post”, :collection =\> @posts %\>  
\<%= “Pages: #{pagination\_links(@pages)}” if paginated? %\>
