# Changing protocol or urls in will\_paginate

**URL:** <https://www.ruby-forum.com/t/changing-protocol-or-urls-in-will-paginate/195291>\
**Category:** Ruby\
**Created:** [September 21, 2010, 9:32am UTC](https://www.ruby-forum.com/t/changing-protocol-or-urls-in-will-paginate/195291 "2010-09-21T09:32:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cnicolaou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/7bcc69/32.png) [@cnicolaou](https://www.ruby-forum.com/u/cnicolaou)\
**Post date:** [September 21, 2010, 9:32am UTC](https://www.ruby-forum.com/t/changing-protocol-or-urls-in-will-paginate/195291/1 "2010-09-21T09:32:16Z")

</div>

Hey,

I’ve been looking to override the default protocol provided with  
will\_paginate.

Is there a chance anyone knows how to do that?

I tried doing so using this helper but it never works since url\_for is  
accepting a string (page)

* * *

class PaginationListLinkRenderer \< WillPaginate::LinkRenderer

def to\_html  
links = @options[:page\_links] ? windowed\_links : []

```
links.unshift(page_link_or_span(@collection.previous_page,

```

‘previous’, @options[:previous\_label]))  
links.push(page\_link\_or\_span(@collection.next\_page, ‘next’,  
@options[:next\_label]))

```
html = links.join(@options[:separator])
@options[:container] ? @template.content_tag(:div, html,

```

html\_attributes) : html  
end

protected

def windowed\_links  
visible\_page\_numbers.map { |n| page\_link\_or\_span(n, (n ==  
current\_page ? ‘current’ : nil)) }  
end

def page\_link\_or\_span(page, span\_class, text = nil)  
text ||= page.to\_s  
if page && page != current\_page  
page\_link(page, text, :class =\> span\_class)  
else  
page\_span(page, text, :class =\> span\_class)  
end  
end

def page\_link(page, text, attributes = {})  
@template.content\_tag(:span, @template.link\_to(text, url\_for(page)),  
attributes)  
end

def page\_span(page, text, attributes = {})  
@template.content\_tag(:span, text, attributes)  
end

end

---

<div class="post-metadata">

**Author:** ![cnicolaou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/7bcc69/32.png) [@cnicolaou](https://www.ruby-forum.com/u/cnicolaou)\
**Post date:** [September 21, 2010, 10:09am UTC](https://www.ruby-forum.com/t/changing-protocol-or-urls-in-will-paginate/195291/2 "2010-09-21T10:09:30Z")

</div>

Please post questions about Rails to a Rails forum.

This list is for Ruby, the programming language. Rails is a big  
application which just happens to be written _in_ Ruby. Many (perhaps  
most) of the people on this list don’t have any interest in Rails.

---

<div class="post-metadata">

**Author:** ![cnicolaou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/7bcc69/32.png) [@cnicolaou](https://www.ruby-forum.com/u/cnicolaou)\
**Post date:** [September 21, 2010, 10:12am UTC](https://www.ruby-forum.com/t/changing-protocol-or-urls-in-will-paginate/195291/3 "2010-09-21T10:12:23Z")

</div>

Brian C. wrote:

> Please post questions about Rails to a Rails forum.
> 
> This list is for Ruby, the programming language. Rails is a big  
> application which just happens to be written _in_ Ruby. Many (perhaps  
> most) of the people on this list don’t have any interest in Rails.

Hey Brian,

Yep true, will move that to another list.

But i just thought that will\_paginate is also used outside the Rails  
world and is written in Ruby, as you probably know.

---

<div class="post-metadata">

**Author:** ![cnicolaou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/7bcc69/32.png) [@cnicolaou](https://www.ruby-forum.com/u/cnicolaou)\
**Post date:** [September 21, 2010, 10:15am UTC](https://www.ruby-forum.com/t/changing-protocol-or-urls-in-will-paginate/195291/4 "2010-09-21T10:15:17Z")

</div>

Please ask in a Rails forum.

On Tue, Sep 21, 2010 at 4:12 AM, Costa Nicolaou \<

---

<div class="post-metadata">

**Author:** ![cnicolaou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/7bcc69/32.png) [@cnicolaou](https://www.ruby-forum.com/u/cnicolaou)\
**Post date:** [September 21, 2010, 10:16am UTC](https://www.ruby-forum.com/t/changing-protocol-or-urls-in-will-paginate/195291/5 "2010-09-21T10:16:17Z")

</div>

Diego V. wrote:

> Please ask in a Rails forum.
> 
> On Tue, Sep 21, 2010 at 4:12 AM, Costa Nicolaou \<

Alright, cheers guys.

This is now solved.
