0
votes

Ember itself is awesome but its docs are cumbersome and complicated. I spent 2 weeks and haven't got a solid grasp of it yet. And most difficult part for me is how Ember-Data integrates into Ember.

For example, for the new action I create the new record of Group model in appropriate route like so:

model: ->
  Twicl.Group.createRecord
    access: 'public'

Then I catch submit event and do the following in the controller:

  save: (record) ->
    record.save().then =>
      @transitionTo 'groups'

It's expected to get to groups.index route if there are no errors and it's working, but in collection I see not only recently saved record but (I guess) its prototype with no data in attributes as well.

The rude solution is to filter model in the index controller:

#instead of 
model: ->
  Twicl.Block.find()
#do
model: ->
  Twicl.Block.find(isNew: false)

Is that it? Or I missed something? Why we can't just get a brand-new collection on controller init?

Also I would appreciate any links to the actual guides (except of official guides and API of course), all that I googled is irrelevant because of old versions of both Ember and Ember-Data. :(

1

1 Answers

1
votes

The TRANSITION document has a lot of good info about getting onto beta 1/2 : https://github.com/emberjs/data/blob/master/TRANSITION.md

Instead of

Twicl.Group.createRecord()

now you should do

this.store.createRecord('group')

And instead of

Twicl.Block.find({isNew: false}) 

you'd do

this.store.find('block',{isNew : false})