Savage Beast: where are the pagination_links calculated?

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

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

I (so) forgot that pagination_links was built in…

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

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

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