# How to pass"page" parameter to xxx\_path or xxx\_url

**URL:** <https://www.ruby-forum.com/t/how-to-pass-page-parameter-to-xxx-path-or-xxx-url/90155>\
**Category:** Rails\
**Created:** [March 26, 2007, 2:22pm UTC](https://www.ruby-forum.com/t/how-to-pass-page-parameter-to-xxx-path-or-xxx-url/90155 "2007-03-26T14:22:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 26, 2007, 2:22pm UTC](https://www.ruby-forum.com/t/how-to-pass-page-parameter-to-xxx-path-or-xxx-url/90155/1 "2007-03-26T14:22:47Z")

</div>

Dear all,

In my app, i uses named route to point to a list page. This is a  
paginated list. I try to go to a specific page by passing the “page”  
parameter to the xxx\_path method in link\_to call, but this method  
doesn’t accept additional hash. So my question is is there a way to  
construct a link to a specific page in pagination using xxx\_path  
method?

Thanks,

- Chuong

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 26, 2007, 3:07pm UTC](https://www.ruby-forum.com/t/how-to-pass-page-parameter-to-xxx-path-or-xxx-url/90155/2 "2007-03-26T15:07:58Z")

</div>

Use xxx\_url(params).

Jason

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 26, 2007, 4:09pm UTC](https://www.ruby-forum.com/t/how-to-pass-page-parameter-to-xxx-path-or-xxx-url/90155/3 "2007-03-26T16:09:12Z")

</div>

xxx\_path(:id =\> @mymodel.id)

xxx\_url(:id =\> @mymodel.id)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 26, 2007, 7:05pm UTC](https://www.ruby-forum.com/t/how-to-pass-page-parameter-to-xxx-path-or-xxx-url/90155/4 "2007-03-26T19:05:52Z")

</div>

Hey,

the standard method is to pass a hash for everything instead of using  
positional parameters:

foos\_path(:parent\_id =\> ‘a\_parent’, :page =\> 2)

An alternative is to use my resource\_fu plugin [1] which does allow  
mixing of positional and hash parameters in your url helpers - though  
that’s not the _only_ change to url helpers that it makes so you may  
want to check out the README file to make sure its not introducing  
behavior you’d rather not have.

Regards,  
Trevor

[1] - [http://agilewebdevelopment.com/plugins/resource\_fu](http://agilewebdevelopment.com/plugins/resource_fu)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 27, 2007, 8:50am UTC](https://www.ruby-forum.com/t/how-to-pass-page-parameter-to-xxx-path-or-xxx-url/90155/5 "2007-03-27T08:50:54Z")

</div>

Hi,

I’ve applied your suggestion, but instead of taking parameters which  
match the named route description and only put the remained parameters  
in the format of param1=value1&param2=value2…, it put all parameters  
under that format.

Luckily in my case, the value of parameters in named route get  
inherited from the current url so I just left out those parameters in  
the xxx\_path call, and it works now. However, I still want to know in  
the case which these parameters not inherited, how can we pass all  
parameters.

Thank you for your help.

- Chuong
