I'm building an application with Ember and Rails which has a contact form for new customers with the following fields:
- name
- phone
- subject
- message
The Rails backend has already models for customer and messages. The attributes email
, name
and phone
are customer data and subject
and message
will be part of the messages model in Rails.
Now, I'm wondering how I should design the ember model since the data of the form has to be distributed to two different backend models. I'm thinking of:
- Having a message and a customer model ready in Ember and trying to split the data somewhere in Ember and save to the corresponding models. (Seems complicated).
- Creating a "virtual" model in Rails which receives data from a contact form model in Ember with exactly the submitted fields. The contact model in Rails sorts the incoming data out and saves it correspondingly to customer and message.
I would probably go for the second option since I'm more experienced in Rails then in Ember but I hope somebody could give me a hint what is the proper way to handle models which have no exact equivalent on the backend.
Aucun commentaire:
Enregistrer un commentaire