Ember Design/Best Practices for Large Scale Projects

Great point. I suggest that a “Best Practices” category be made to foster this very sort of discussion.

I would suggest it myself but I think I’ve used up my official suggestions for awhile with my Ember-CLI category suggestion :wink:

I’ve started a github markdown document here: https://github.com/chrisjlee/ember-best-practices/blob/master/README.md

Would love to collaborate with someone.

1 Like

I’m not sure on the specifics of your project, but as for the project layout as a whole I have come up with a structure that has worked well for me. I am using lineman-js with the lineman-ember and lineman-bower plugins, and they have been fantastic. I use bower for asset management, hence the lineman-bower plugin. Lineman takes care of compilation of the code, livereload of assets, and many other things. My file structure looks like the following (just a sample from a project):

I have tried the controllers, models, routes, etc. approach because I came from rails, but I really have grown to dislike that approach as the project gets bigger. It’s easier for me to say, “I need something for users so I need to go to the users folder”. That is a personal preference. I hope any of that helped.

1 Like

I’m currently doing something very similar in my current work project. We’ve mounted multiple Ember apps onto a single Rails app that functions primarily as an API server for the multiple Ember apps. We’re using the ember-rails gem which gives you a few nice helpers to bootstrap your project structure. Each Ember app is focused on specific user roles (manager, company reps, etc.) so the content can be tailored towards what information and functionality they need.

Doing all of this efficiently may require some fairly in depth knowledge of Rails routing, layouts, and the asset pipeline, so if you’re not comfortable with Rails you may want to look at a different solution.

Feel free to let me know if you have any specific questions and I’ll see where I can help.

And what about splitting the project in several ones, like components, models, etc to reuse in a main project. Is there a recommended way to do that in ember-cli? I imagine the addon mechanism could be used but seems tied to publishing on npm which may not be desirable in many projects

I’m doing that in both my personal projects and some client projects, splitting out components into their own repositories as ember-cli addons and including them into the main project(s).

You don’t have to publish to npm, you can set them as private and just include the git repo in the package.json.

Eg:

"devDependencies": {
  ...
  "my-component":       "git+https://github.com/foo-corp/my-component.git#v0.1.2",
  "my-other-component": "git+https://github.com/foo-corp/my-other-component.git#master"
  ...
}

Thank you very much, I´ll try that

I would be very interested in seeing how you’ve done this. I also want to split my app into ‘main’ and ‘admin’ where most of my models in the admin app extend the models from the main app. I’d then also like to only serve admin.js/admin.css assets to logged-in admin users.

How are you mounting Ember apps in your Rails app? I want to do the same.

At the time we were using the Ember Rails gem and utilizing the asset pipeline and multiple layouts to serve up the different Ember apps we were building. We’ve since migrated everything over to Ember CLI and are using Rails for the API only. If you’re planning on investing any significant time in Ember, I would suggest doing this as the community appears to be standardizing around the Ember CLI tool. We just serve the static Ember files up via Apache/nginx and they communicate with the Rails app. If you’re utilizing cloud services there are plenty of great Rails hosts and CDNs for your Ember CLI generated static apps.

Best of luck to you :beers:

Thanks, that’s exactly how I’m doing things. I thought the Ember app as an engine in the Rails app was an interesting idea.

Right now I’m using Rails for api only and loving Ember-CLI.

Coming from the PHP 5, I could say in Symfony 2 they introduce the concept of Bundle. I think this misses a lot in Ember, at least something like that… :confused: