1

I am using ember cli and Ember Data. My requirement is to keep ember model in Models sub folder.

Ex. My Model Name is mymodel and have kept it inside app\models\myfolder\mymodel.js folder. store.find works with following syntax -

this.store.find('myfolder.mymodel');

Above syntax generates service URL as http://localhost:4200/myfoldermymodel where as my service can be accesssed using URL http://localhost:4200/mymodel only. If I try to override buildURL or pathForType on RESTAdapter though service call is successful model is not getting populated.

How do I put model in subfolders?

ryanyuyu
  • 6,366
  • 10
  • 48
  • 53
Manish
  • 21
  • 8
  • Add relevant code please – sinhayash Jul 01 '15 at 15:24
  • I use model subfolders as namespace in the same way in Ember and in the backend. It works without overriding any adapter's methods – artych Jul 01 '15 at 16:03
  • Hi Artych could you please elaborate on "and in the backend". My issue is with ember generated URL. It generates URL as myfoldermymodel but the service can be accessed using mymodel only. – Manish Jul 01 '15 at 18:20
  • For example I have namespaced model `docs/account` in Ember and in Rails. In ember route `store.find('docs/account')` generates `GET .../docs/accounts` request (this is expected for namespaced model names) and my rails backend fetches `docs/accounts` and sends JSON payload `{"docs/accounts":[{"id":1, "no":123123, ... },{...}]}` – artych Jul 01 '15 at 20:21
  • Recommend against this. I understand you wanting to group your models into subdirectories, but you will spend more time figuring this out than will be worth your while. There's a question about this on SO somewhere but I can't find it now. –  Jul 02 '15 at 06:28
  • @torazaburo what's your recommendation for avoiding this? I'm running into something similar that mentioned but can't find anything that suggests how to accomplish this – Leo Correa Jun 25 '16 at 20:56

0 Answers0