# Savage Beast: where are the pagination\_links calculated?

**URL:** <https://www.ruby-forum.com/t/savage-beast-where-are-the-pagination-links-calculated/115538>\
**Category:** Rails\
**Created:** [September 26, 2007, 2:56am UTC](https://www.ruby-forum.com/t/savage-beast-where-are-the-pagination-links-calculated/115538 "2007-09-26T02:56:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![LAB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ba8739/32.png) [@LAB](https://www.ruby-forum.com/u/LAB)\
**Post date:** [September 26, 2007, 2:56am UTC](https://www.ruby-forum.com/t/savage-beast-where-are-the-pagination-links-calculated/115538/1 "2007-09-26T02:56:03Z")

</div>

I am trying to track down where the pagination\_links are calculated.  
I have integrated SB into my site, and the show.rhtml for the topics  
controller references them like this:

\<%= \_('Pages:') %\> **\<%= pagination\_links @post\_pages, :window\_size =\> 10 %\>**

The problem is, the pagination\_links are being built wrong. They are  
missing the forums id in the url and are defaulting to: …/topics/9?  
page=2 notice there is not a “forums” part to that URL. The URL  
should be …/forums/6/topics/9?page=2.

Right now, this produced a Action Controller exception: Couldn’t find  
Forum without an ID.

It all makes sense … now I just need to find where I can change how  
“pagination\_links” are built.

This must be a standard problem … unless I’ve mucked up my  
environment too much without realizing it??

Thanks in advance!  
LAB

---

<div class="post-metadata">

**Author:** ![LAB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ba8739/32.png) [@LAB](https://www.ruby-forum.com/u/LAB)\
**Post date:** [September 26, 2007, 3:17am UTC](https://www.ruby-forum.com/t/savage-beast-where-are-the-pagination-links-calculated/115538/2 "2007-09-26T03:17:42Z")

</div>

I don’t have the source in front of me - but I’d look for the helper  
“pagination\_links”, and modify it to take a forum\_id param.

Looking at the source for the helper should give you what you need-  
You’ll also need to over-ride the view.

If you find a solution I’ll commit the fix.

Cheers,  
Jodi

---

<div class="post-metadata">

**Author:** ![LAB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ba8739/32.png) [@LAB](https://www.ruby-forum.com/u/LAB)\
**Post date:** [September 26, 2007, 3:29am UTC](https://www.ruby-forum.com/t/savage-beast-where-are-the-pagination-links-calculated/115538/3 "2007-09-26T03:29:59Z")

</div>

I (so) forgot that pagination\_links was built in…

[http://api.rubyonrails.org/classes/ActionView/Helpers/](http://api.rubyonrails.org/classes/ActionView/Helpers/)  
PaginationHelper.html#M000504

the other way to manage this, would be to override  
find\_forum\_and\_topic to guess the form id given a specific topic id

something like:

def find\_forum\_and\_topic  
if params[:id] && !params[:form\_id]  
@topic = Topic.find(params[:id])  
@form = @topic.forum  
end  
…  
end

Take a look at the base beast topic controller find\_forum\_and\_topic  
before\_filter for guidance.

cheers,  
Jodi

---

<div class="post-metadata">

**Author:** ![LAB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ba8739/32.png) [@LAB](https://www.ruby-forum.com/u/LAB)\
**Post date:** [September 26, 2007, 4:24am UTC](https://www.ruby-forum.com/t/savage-beast-where-are-the-pagination-links-calculated/115538/4 "2007-09-26T04:24:57Z")

</div>

Ahhhhh … that’s why I couldn’t find pagination\_links in any of my SB  
helper files. I added your puedo code to my topic controller and it  
worked great!!! For others … very specifically:

def find\_forum\_and\_topic  
if params[:id] && !params[:forum\_id]  
@topic = Topic.find(params[:id])  
@forum = @topic.forum\_id  
else  
@forum = Forum.find(params[:forum\_id])  
@topic = @forum.topics.find(params[:id]) if params[:id]  
end  
end

Thanks for the work around!!

Cheers!  
LAB
