mercredi 2 décembre 2015

Create model when depends other model

I'm bit confuse in how create a event in my createRecord action, when i'm returning in the route 3 models:

return RSVP.hash({
  event: this.store.createRecord('event'),
  hiws: this.store.findAll('hiw'),
  tips: this.store.findAll('tip')
});

Event is what i want create, but i'm making a each in the hiws and tips in the hbs, because one event has one hiw and one tip.. like this:

            <select class="tables__sidebar-select">
              {{#each model.tips as |tip|}}
                <option class="tables__sidebar-option">{{tip.name}}</option>
              {{/each}}
            <select>

And the same with hiws. I'm trying like this: inside my createRecord action i have:

  let hiws = this.get('model.hiws');
  let tips = this.get('model.tips');
  let notify = this.get('notify');

  let event = this.get('store').createRecord('event', {
    hiws: hiws,
    tips: tips
  });

  event.save()

I'm trying to create a event with all properties plus hiw and tip, but the selected hiw and tip.




Aucun commentaire:

Enregistrer un commentaire