Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd querystring parameters to link_to
    primarykey
    data
    text
    <p>I'm having difficultly adding querystring parameters to link_to UrlHelper. I have an Index view, for example, that has UI elements for sorting, filtering, and pagination (via will_paginate). The will_paginate plugin manages the intra-page persistence of querystring parameters correctly.</p> <p>Is there an automatic mechanism to add the querystring parameters to a give named route, or do I need to do so manually? A great deal of research on this seemingly simple construct has left me clueless.</p> <p><strong>Edit</strong></p> <p>Some of the challenges:</p> <ol> <li><p>If I have two querystring parameters, bucket &amp; sorting, how do set a specific value to one of these in a link_to, while preserving the current value of the other? For example:</p> <pre><code>&lt;%= link_to "0", profiles_path(:bucket =&gt; '0', :sorting=&gt;?? ) %&gt; </code></pre></li> <li><p>If I have multiple querystring parameters, bucket &amp; sorting &amp; page_size, and I want to set the value to one of these, is there a way to 'automatically' include the names and values of the remaining parameters? For example:</p> <pre><code>&lt;%= link_to "0", profiles_path(:bucket =&gt; '0', [include sorting and page_size name/values here] ) %&gt; </code></pre></li> <li><p>The will_paginate plugin manages its page variable and other querystring variables automatically. There doesn't seem to be an automatic UI element for managing page size. While I've seen code to create a select list of page sizes, I would rather have A elements for this (like SO). Part of this challenge is related to #2, part is related to hiding/showing this UI element based on the existence/non-existence of records. Said another way, I only want to include page-size links if there are records to page. Moreover, I prefer to automatically include the other QS variables (i.e. page, bucket, sorting), rather than having to include them by name in the link_to.</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload