ember-rails allows you to include Ember.JS into your Rails 3.x application.
The gem will also pre-compile your handlebars templates when building your asset pipeline. It includes development and production copies of Ember.
You can see an example of how to use the gem here. There is also a great tutorial by Dan Gebhardt called "Beginning Ember.js on Rails" which is a great read if your just starting out with Rails and Ember.js
Add the gem to your application Gemfile:
bundle install and add the following line to
//= require ember
Ember-rails also provides a way to run Ember in development mode, you
can switch out your require statement
//= require ember to use the
dev copies like so:
//= require ember-dev
Ember does not require an organized file structure. However, ember-rails allows you
rails g ember_rails:bootstrap to create the following directory structure under
controllers/ helpers/ models/ templates/ views/
Additionally, it will add the following lines to
By default, it uses the Rails Application's name and creates an
file to setup application namespace and initial requires:
//= require ember //= require ember/app
If you want to avoid
.gitkeep files, use the
skip git option like
rails g ember_rails:bootstrap -g.
Ask Rails to serve HandlebarsJS and pre-compile templates to Ember
by putting each template in a dedicated ".js.hjs" or ".handlebars" file
and including the assets in your layout:
Bundle all templates together thanks to Sprockets,
//= require_tree .
Now a single line in the layout loads everything:
Note on Patches/Pull Requests
- Fork the project.
- Make your feature addition or bug fix.
- Add tests for it. This is important so I don't break it in a future version unintentionally.
- Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
- Send me a pull request. Bonus points for topic branches.