Note that there are some explanatory texts on larger screens.

plurals
  1. PORails: Route ignoring parameter
    primarykey
    data
    text
    <p>I am using the below to render a collection:</p> <p><code>&lt;%= render :partial =&gt; 'mini_release', collection: group, as: :r %&gt;</code></p> <p>And the following routes:</p> <pre><code>constraints(domain: /[a-zA-Z0-9-]+/i, page: /[0-9]+/, :format =&gt; 'html') do get ':domain', :to =&gt; 'sites#show', as: :site get ':domain/releases(/p-:page)', :to =&gt; 'sites#releases', as: :site_releases, :constraints =&gt; { :format =&gt; /(json|html)/ } get ':domain/release/:release_id', :to =&gt; 'sites#release', as: :site_release end </code></pre> <p>All good so far, the routing works and the rendering works. However, when calling the path below inside the partial "mini_release", it builds an incorrect url:</p> <p><code>&lt;%= link_to site_release_path(:domain =&gt; r.site.domain, :release_id =&gt; r), :class =&gt; 'col-xs-6' do %&gt;</code></p> <p>Where <code>r</code> is a model of <code>Release</code> and has one <code>Site</code> (which has an attribute <code>domain</code>).</p> <p>The URL generated is correct in terms of the URL is builds. But the <code>:domain</code> section is always incorrect and is the current models object.</p> <p>For example, say the page I am currently on is: <code>/site-one/release/my-release/</code> and I am rendering the partials, all the partials result in <code>/site-one/release/the-correct-slugs</code>, when they should be <code>/some-other-site/release/the-correct-slugs</code>. I've tried multiple formats for the routes - with and without the variable associations - but none work. It seems the route is taking the current route <code>:domain</code> parameter instead of the given one.</p> <p>How can I ensure the route stops looking at the current <code>:domain</code> parameter?</p> <p>This may have something to do with this <a href="https://github.com/rails/rails/issues/9829" rel="nofollow">https://github.com/rails/rails/issues/9829</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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