ruby on rails - Can't Retrieve Model Data -


i'm starting use ember.js rails 3.2.13 through ember-rails gem. unable access data through browser console following command:

var posts = app.post.find(); 

it returns undefined on console, following outputted on server logs:

started "/posts" ....... processing postscontroller#index json parameters: {"posts"=>{}} post load select "posts".* "posts" completed 200 ok ..... 

please let me know if doing wrong or missing something. thanks


here steps took install ember-rails

1) add ember-rails gem file

2) after bundle install, run:

rails g ember:bootstrap

there mvc directories, app.js, application.js, router.js, , store.js.

store.js has following contents:

app.store = ds.store.extend({   revision: 11 }); 

3) did

rails g scaffold post title:string body:text 

next added active_model_serializer gem , generated serializer post.

can check actual response server (in chrome, open inspector, find request in network panel , @ response)? make sure server returning correct json. (also obviously, i'm assuming you've created post models on rails server).

next, make sure have proper attributes listed under serializer; think default includes id.

you can try passing id find: app.post.find(1) , again see server response is.

app.post.find() async returns promise data -- should never returning undefined. can call .then() on model promise , pass function expecting loaded model argument run promise resolves.

hope helps. try checking server response , let me know if of unclear.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -