Note that there are some explanatory texts on larger screens.

plurals
  1. POEmber-data DS.Model.find() doesn't seems to work
    primarykey
    data
    text
    <p>I purchased play by play of Ember.js at peepcode.com and followed as the video offered.</p> <p>So, I set the Model and Serializer and Controllers up in Rails.</p> <p>When I typed URL like this.</p> <pre><code>http://localhost:3000/actors/wycats </code></pre> <p>the JSON response rendered as I expected. (It's probably Ember-data's expecting JSON form..right?)</p> <pre><code> { "actor": { "id": 1, "blog": "http://www.yehudakatz.com", "company": "Tilde, Inc.", "email": "wycats@gmail.com", "gravatar_id": "428167a3ec72235ba971162924492609", "location": "San Francisco", "login": "wycats", "name": "Yehuda Katz", "actor_type": "User" } } </code></pre> <p>So I set up the Store and Actor Model in ember.js</p> <pre><code> GithubScore.Store = DS.Store.extend({ revision: 11, adapter: "DS.RESTAdapter" }); GithubScore.Actor = DS.Model.extend({ login: DS.attr('string'), name: DS.attr('string'), gravatarId: DS.attr('string'), location: DS.attr('string'), blog: DS.attr('string') }); </code></pre> <p>And I launched my Ember App, No error occurred.</p> <p>but when I tried to get a model using console ( I already had a model saved in Rails DB with ID of 1 )</p> <pre><code> GithubScore.Actor.find(1) </code></pre> <p>It returns a Class, No error occurred, but When I try to get an attribute of it. it returns only null, although the model's status 'isLoaded'</p> <pre><code> GithubScore.Actor.find(1).get('isLoaded') =&gt; true GithubScore.Actor.find(1).get('blog') =&gt; null </code></pre> <p>and I found that when I call GithubScore.Actor.find(1).get('isLoaded') repeatly at first time it returns only false, but when I try to get an attribute 'isLoaded' is changed to true immediately.</p> <pre><code> GithubScore.Actor.find(1).get('isLoaded') =&gt; false (for many times) GithubScore.Actor.find(1).get('blog') =&gt; null GithubScore.Actor.find(1).get('isLoaded') =&gt; true (immediately changed) </code></pre> <p>and when I try .toJSON() method to model as the video did. It throws an error.</p> <pre><code> GithubScore.Actor.find(1).toJSON() =&gt; TypeError: Object &lt;GithubScore.Actor:ember272:1&gt; has no method 'toJSON' </code></pre> <p>One thing I curious about is that, though GithubScore.Store object is extended from DS.Store.</p> <p>It doesn't have find(type, id) method which DS.store already has.</p> <p>I can't find what the problems are. Would you give me some help?</p> <p>Thank you for reading!</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.
 

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