So I was trying to setup using pods as written in the ember-cli docs - by setting the podModulePrefix to ‘my-appname/pods’ . Turns out that generating a route for instance works nice - its put into the pods directory. But running the app does not include stuff from the pods directory. When I put everything on the app root it works. Over on github I found this discussion where pods directory will be removed totally, everything should be put under the app root directory (quite dumb , if you have lots of stuff… ). On the other hand I find threads in forums where it says: ‘yeh, putting stuff into pods directory just works fine’ … so… what should I now believe in? In the end its not working for me, its frustrating as always (working with ember now since a few months) to get stuff running ‘the right way’, whereas there is no right way because everything is changing and docs are old and also tutorials and so on…
Can I ask what you mean by “stuff”? I am using pods successfully and have set a podModulePrefix without issue, but perhaps I’m not using the type of object you are.
The one thing I did find is that in addons you just put “pods” as the podModulePrefix and in an application you use “/pods” where is the same as the modulePrefix you have set.
Sure, you can ask . Sorry for not being to specific…
ember-cli: 1.13.1 ember: 1.13.3 ember-data: 1.13.5
The environment.js (tried with frontend/pods and just /pods:
modulePrefix: 'frontend', podModulePrefix: 'frontend/pods',
The directory structure:
app app/adapters app/helpers app/models app/pods app/pods/index app/pods/index/route.js app/pods/index/template.hbs app/pods/events app/pods/events/index/route.js app/pods/events/index/template.js app/pods/events/edit/route.js app/pods/events/edit/template.js // and some more of that 'stuff'
Another thing to note is, that the resolver log does not give a hint, that he tries to lookup in the pods directory…
Supposedly it has worked for someone, somewhere, but podModulePrefix has never worked for me. There is a proposal to remove it entirely, and the smart money is on that going through at some point. If you have lots of stuff, you’ll either have lots of stuff in the pods directory or lots of stuff in the app directory. If you’re truly sticking with pods, /app won’t have much else in it. A much more sane approach to using pods is to add
usePods: true to the
.ember-cli file in the root directory. After that, all your generator commands will use pods.
I did add usePods and it works for the generators but not when the resolver is trying to put all the template stuff together… so usePods or --pods while generating is not really the problem…
Oh! That’s unusual. Can you post up a representative sample of your file tree?
Okay… I understood now, that I would not need folders like ‘adapters’ or ‘services’ etc anymore, so I don’t think the app-folder will be a total mess because I can put the current adapter into application/adapter.js and so on… So… finally I think that a pods folder and podModulePrefix is not needed really and I’m going to follow whats suggested … What I can say about working with ember is… it does not become boring
Bingo! That said, a caveat: Most Ember objects are plural, but models and model-specific-adapters are singular. This can lead to having pods like “posts” AND “post”, “comments”, AND “comment,” etc. For that reason, you’ll see people override
usePods by passing the
--pod flag* when you’re creating models or model-specific-adapters to keep them in the models folder.
--pod just inverts whatever the
usePods option is currently set to. So, if it’s
ember g model modelName --pod will put the model in a non-pod structure
If you have “lots of stuff” it most likely means your app is structured poorly–it’s too “flat”. It you have “lots of stuff” then even if you create a pods directory it will still be too full of things. I switched away from pods and never looked back.
Models are obviously related to routes and pods, but in some sense they are orthogonal. There might be models with no routeable logic, and there might be multiple pieces of routeable logic related to one model. Therefore, aside from the pluralization issue, it makes sense to me to keep models in a separate models directory. Having said that, in my node app, I have chosen to include models in the same directory with routes and controllers, and I use singular form for everything, which works just fine.
My take on pods is it is perfect for use with hierarchical types of classes. Router, controllers, templates, and sometimes components can all be represented as such easily.
Pods is definitely something worthy in organizing files. Am okay with the file structure and I just make my routes.js file reveal the structure of my app.