my recent reads..

Atomic Accidents: A History of Nuclear Meltdowns and Disasters; From the Ozark Mountains to Fukushima
Power Sources and Supplies: World Class Designs
Red Storm Rising
Locked On
Analog Circuits Cookbook
The Teeth Of The Tiger
Sharpe's Gold
Without Remorse
Practical Oscillator Handbook
Red Rabbit

Monday, March 19, 2012

Rails + Ember + MongoDB + bootstrap

I was fired up to try out ember.js after seeing Cameron's presentation at the last Singapore Ruby Brigade meetup.

Ember is one of the many javascript MVC frameworks that have been sprouting up over the past year, and it seems to offer a nice level of abstraction. I was quite interested to see how it might fit for a Rails/MongoDB application we're currently working on, so a few tests were in order.

I hosted some tests on a Rails 3.2.2 base, and threw in a whole bunch of technologies to see how well they play together. The story so far:
  • ruby 1.9.3 + rails 3.2.2 with rspec-rails and factory_girl_rails for testing
  • haml - templating for a pure rails alternative to compare with the ember app
  • mongoid - using MongoDB for server-side persistence, to see how this plays with ember
  • inherited_resources - for super thin controllers. Works beautifully with ember and Mongo (I literally wrote just a single line in the server-side controller
  • ember.js - the ember distribution...
  • ember-rails - makes it easy to add ember to the project (gem installed with bundler)
  • CoffeeScript - for the ember scripting
  • ember-rest - a simple RESTful resource adapter between ember and rails
  • twitter-bootstrap-rails - a gem packaging of twitter bootstrap (adds LESS to the asset pipeline)

Surprisingly, this all hangs together without too much fuss! You can see & fork the demo at rails-ember-mongo-bootstrap-demo.



What's next?
  1. Testing: I've got RSpec in the project for conventional testing, but I haven't investigated the best ways to test the ember app itself yet.
  2. Relations: perhaps switching to ember-data to test some non-trivial model associations
  3. ember-bootstrap: adds bootstrap components to ember. Sounds promising but my initial attempts to use it weren't too successful

Blogarhythm: Remember - Jimi Hendrix