jeudi 21 avril 2016

Ember Data error while processing route this.store.findALL is not a function

I'm currently going through the ember.js guides, and I'm getting hung up on the Ember Data section. Ember Data Guide

The tutorial shows how to create an Ember Data model and use it in conjunction with mirage to render some basic rentals info on the index page.

My code appears to be the same as the tutorial (see note at bottom), but my index page doesn't display anything, and I get these errors in the chrome console:enter image description here


Any help anyone could offer would be very much appreciated.


This is my app/models/rentals.js

import Model from 'ember-data/model';
import attr from 'ember-data/attr';

export default Model.extend({
    title: attr(),
    owner: attr(),
    city: attr(),
    type: attr(),
    image: attr(),
    bedrooms: attr()
});

app/mirage/config.js

export default function() {
  this.get('/rentals', function() {
    return {
      data: [{
        type: 'rentals',
        id: 1,
        attributes: {
          title: 'Grand Old Mansion',
          owner: 'Veruca Salt',
          city: 'San Francisco',
          type: 'Estate',
          bedrooms: 15,
          image: 'http://ift.tt/1Q04rYy'
        }
      }, {
        type: 'rentals',
        id: 2,
        attributes: {
          title: 'Urban Living',
          owner: 'Mike Teavee',
          city: 'Seattle',
          type: 'Condo',
          bedrooms: 1,
          image: 'http://ift.tt/20f2bMx'
        }
      }, {
        type: 'rentals',
        id: 3,
        attributes: {
          title: 'Downtown Charm',
          owner: 'Violet Beauregarde',
          city: 'Portland',
          type: 'Apartment',
          bedrooms: 3,
          image: 'http://ift.tt/1Q04seM'
        }
      }]
    };
  });
}

app/routes/index.js

    import Ember from 'ember';

    export default Ember.Route.extend({
      model() {
        return this.store.findALL('rental');
      }
    });

app/templates/index.hbs

<h3>Welcome to Super Rentals</h3>

<p>
  We are dedicated to helping you!
</p>


  <h2></h2>
  <p>Owner: </p>
  <p>Type: </p>
  <p>Location: </p>
  <p>Number of Bedrooms: </p>


About Us!
Contact Us!




Note-- The ember.js guide is slightly out of date with the current version of ember, so I'm also using these edits to the ember-data.md file.




Aucun commentaire:

Enregistrer un commentaire