Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>EDIT: Setting up a route with a single dynamic segment to return an array of objects</strong></p> <p>You can still keep the same route structure:</p> <pre><code>this.route('lifts', { path: '/lifts/:county_ids' }); </code></pre> <p>And then override the <code>model</code> hook to parse <code>params.county_ids</code> into a query string:</p> <pre><code>model: function(params) { ids = parseQueryIds(params.county_ids) // you have to parse this in a format that your server will accept App.Lift.find({query: ids}) // returns an record array } </code></pre> <p>This will preserve the url structure (if you go to <code>/lifts/1,2,3</code>, that url will be saved) but also returns an array of items.</p> <p><strong>END EDIT</strong></p> <p>This is happening because <code>App.Lift.find</code>, when passed a string, will try to query by id for a single object, but your response from the server is returning multiple objects (id 1, id 2, etc). </p> <p>When you do <code>App.Lift.find(params.county)</code> (let's say <code>params.county</code> is "1"), Ember will make a <code>GET '/lifts/1'</code>. But for whatever reason, your server is returning JSON with a key that has an array.</p> <p>Can you check that</p> <ol> <li>the GET request ember is making is indeed for a single id? If you're using chrome, check the network requests -- what is the resource that <code>App.Lift.find(params.county)</code> asks for?</li> <li>that <code>params.county</code> is defined? If it's undefined, you'll be calling <code>App.Lift.find(undefined)</code>, which makes the GET to <code>/lifts</code>, and that might cause your server to return the array of objects.</li> <li>that your server is responding to requests properly when a single id is requested?</li> </ol>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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