A bit of a softball question, but my Google Fu escapes me at the moment.
How do I link to the current page but then specify params to be merged into the query string?
For instance, if the current page is /resources
, I want to be able to specify something like current_page_plus(:param => 'attribute')
that evaluates out to /resources?param=attribute
.
This would hopefully also merge with existing attributes, so if the current page was /resources?a=b&c=d
, then current_page_plus(:c => 'e')
would evaluate to /resources?a=b&c=e
.
You can use url_for
passing the params.
url_for(params.merge(:c => "e"))
If you use an helper like link_to
that internally uses url_for
you can skip the url_for
and pass the has directly.
link_to "Page", params.merge(:c => "e")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With