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
xxx_path(:id => @mymodel.id)
xxx_url(:id => @mymodel.id)
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
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¶m2=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