We are using usePods=true but we want to locate all our models inside of a single app/models folder to avoid the app folder tree from getting so long with the default way of creating a folder for each model directly inside the app folder.
We therefore want:
app/models/customer
app/models/order
app/models/order-line
etc
Is this possible currently whilst maintaining Ember 2.0 compatibility and using pods?
That’s the way I have it setup. When generating the model use the -p flag to negate the pods structure. Eg: ember g model foo-bar -p
You could also manually move your existing model files into the app/models folder too, just be sure to rename the files to the actual model name. Eg: from app/foo-bar/model.js to app/models/foo-bar.js
The Resolver will check both places, although I’m not sure which one takes precedence.
@Panman8201 - Thanks, that works! I had mistakenly generated the models into the app/models folder where each model was put in a sub-folder inside the app/models folder and that obviously wasn’t working for me.
Your suggested method does indeed work for me and is quite a nice way to keep the models separated.
If you turn on all logging in config/environment I’m pretty sure the resolver will log all of it’s lookups. iirc (from many months ago…) The pods were taking precedence. But, bottom line is, as long as you don’t have a model in both locations, the resolver will find your model, wherever it is, and use it accordingly!
@novascape@Panman8201 When the next release of ember-cli goes out (likely v2.0.0), this behavior will change. This PR was recently merged, adding a new --classic flag which will generate in the classic structure. The --pod flag will no longer be inverted, so it will generate in pod structure regardless of the usePods setting.
@balint: What has been your current idiom with regards to organizing your codebase using pods as far as components and sub-components go? How about models, adapters & serializers?
To be honest, I don’t usually use pods because I’m still on the fence about them or I get brought into a project where I don’t have a choice. When I get to pick, my main reasons for not using pods are probably 1) not sure how much they (their looking up and file structure) will still change and 2) I’m very used to the “classic” file structure from Rails and Ember and thus switching to pods would be quite a hurdle and their advantages (to me) do not justify making an effort to overcome that hurdle.
Nope, I’ve just worked with what’s provided by the existing resolver. But I use pods for everything “route” related; routes, controllers, templates. In addition, my components (w/ template) are in their own “components” pod folder. Everything else; adapters, helpers, initializers, mixins, models, services, and styles are non-pods.