this post is out-dated use Lightning Fast Deployments instead
I moved the app which I was doing as part of my Ember.js with Rails series to ember-cli, but just until very recently deployed to heroku.
I want to put my ember-cli output into my
rails/public and then
include the scripts into my application layout
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
I do it like this because I want to include my
csrf_tags in the body
and also have the option of preloading any data if I need to.
Out of topic, but since handling csrf-tags is such a common scenario I wrote rails-csrf, a plugin which you can install through bower for handling CSRF for you.
I came through a script by Jason Madsen(@jason_madsen) which would
take care of building the ember-cli app and putting it under public,
it works great but the final output is under your
which I don’t want.
I modified the script to do a couple of things more.
<%= csrf_meta_tags %>before head (line 40).
<%= yield %>after body (line 43).
application.html.erbwith my final
The script can be found on the following gist
Now with the desired output, is just a matter of
git commit and
git push to heroku.
To make it easier I added the following task to my Rakefile, it:
- Accepts the “env” I want to deploy and the remote name (heroku end-point).
- Moves to the specified env and merges master.
- Runs the
buildscript and commit the changes.
- Push the changes to heroku.
1 2 3 4 5 6 7 8 9 10
A standard deployment would be something like
rake deploy[production, heroku]
It assumes you have a branch called
production and that your remote is called
Thanks to Jason Madsen for his initial script, he also made a rails template knomedia/ember-cli-rails.
The rake task was mostly inspired by DockYard’s ember-cli-plus-backend.
There is still a lot of things to improve which I’ll be blogging about as part of my ember-cli + Rails series. Here’s a list of things:
- Deploying to heroku just the Rails files, currently we include the ember-cli app as well.
- Using cloud front for serving your assets.
Fingerprintingis super simple with broccoli-asset-rev see it in use here.
- Doing lightning fast deployments (see Luke’s Melia talk on Rails Conf).
Learn how to write apps with Ember.js, ember-cli and Ruby on Rails, subscribe to my list and I will let you know every time I publish an article.