@belgoros wrote:
I have 2 models with a many-to-many relations:
- Shop
- Event
Being on
templates/events/index.hbs
page that displays the list of events, how is possible to assign anevent
to ashop
(I have the instance of the current shop everywhere in the application via a servicecurrent-shop
) ?My first idea was to create an end-point on the backend side (`Rails’)
POST /shops/:shop_id/events/:id(.:format) v1/shop_events#handle_event
The difficulty I have on Ember side is how to call the above route from
controllers/events/index.js
controller ?I tried to do as follows:
handleEvent(event) { let event = this.store.peekRecord('event', 1); let shop = this.store.peekRecord('shop', 1); shop.get('events').pushObject(event); shop.save(); }
but, of course Ember tried to hit
PATCH http://localhost:3000/shops/:shop_id
.I’m using
ember-data-url-templates
and override adapters when needed. How to solve that without modifying the existingshop
adapter ?Thank you.
Posts: 3
Participants: 2