Today I ran into a couple of issues/gotchas while attempting to split out an Ember.js-based sub-project into a Rails engine. Here is how I was eventually able to get things going. This is accurate as of Rails 4.0.1 and ember-rails 0.14.0.
Create the Engine
rails plugin new --mountable vendor/engines/my_sub_project
Add Ember-Rails as a dependency
Your newly created engine should have a gemspec file in it, named something like my_sub_project.gemspec. Add the following dependencies to the spec:
s.add_dependency "ember-source", "1.1.2"
You will also need to update each of the configuration options that are tagged with
TODO before proceeding.
You should now be able to call
bundle install to install the Ember.js dependencies.
Bootstrap with Ember.js
Next, you should be able to execute
bundle exec rails generate ember:bootstrap to bootstrap the engine with the Ember.js directory structure and basic files.
Except there is a bug in the current version of ember-rails that I have submitted a patch for, here. Until that has been merged, this command will error out. Feel free to use my branch to get going if it has not been merged by the time you read this.
It is important that you run the rails command with bundler, otherwise the generator will not be found.
That should be it!
After banging my head against the wall for awhile trying to get an Ajax user invite form to work with Devise::Invitable, I finally stumbled upon the solution which was not overly apparent at the time (it is in hindsight, of course).
By default, Devise only responds to HTML requests and you don’t really want to add JSON as a supported navigational format since you want authentication errors to be returned with a 401 status for API formats. However, if you override the default Devise::InvitationsController, you simply need to add JSON to the list of supported response formats:
class Users::InvitationsController < Devise::InvitationsController respond_to :html, :json end
You should read the section Configuring Controllers in the DeviseInvitable README to fully configure your custom controller.
I’ve created a widget to pull traffic data from the excellent Gauges service by GitHub and display it in your Status Board. If you haven’t heard of Status Board yet, it’s a dashboard for showing all sorts of data on your iPad (or big screen TV) developed by Panic, Inc.