MealEtte Tool Review – 2009 Rails Rumble

This past weekend I participated in the 2009 Rails Rumble where I built MealEtte (a combination of Meal and Roulette). The purpose of MealEtte is:

Ever wasted more than 5 minutes figuring out what to eat for dinner tonight? MealEtte is for you. (If you haven’t wasted any time, please let me in on your secret.)

MealEtte is designed to take the guesswork out of meal planning. By entering your Recipes you’ll have access to the MealEtte Roulette O’matic. Using sophisticated computer algorithms, artificial intelligence, and computer-geekery the Roulette O’matic is able to pick random meals for your consumption.

So sit down, get hungry, and spin the wheel.

I entered the Rumble in order to learn about some new tools in the Rails community that I haven’t had a chance to use yet. And learn I did. Here’s a short list of my favorites, the full list is available on my team page:

If I had to pick my favorite three new tools, they would be:


Raphael is a JavaScript library that makes working with SVG easy, which I used to animate the roulette wheel. I ended up with about 50 lines of code to draw a SVG dynamically, animate the wheel spinning, and to get a random recipe from the Rails backend. Here’s a shortened version of function, if you want to see the full function it can be downloaded from MealEtte:

    initialize_spinner = function(options) {
        // ... options initialization removed ...
        var R = Raphael(opts.container, 500, 500);
        var img = R.image(src, -300, 000, 800, 800);
        var value = 180;
        $(opts.trigger).click(function (e) {
              // ... connect to the Rails backend ...
            value += Math.floor(Math.random()*180) + 180;
            img.animate({rotation: value}, 2300, function() {
              // ... popup a facebox lightbox with the results
            return false;

Here’s a quick walk through of the main Raphael functions I used in the animation:

  • var R = Raphael() creates a SVG container at a specific DOM id that is 500×500 pixels.
  • var img = R.image(src, -300, 000, 800, 800); takes the url of the roulette image and embeds it into the container as a 800×800 image.
  • $(opts.trigger).click() binds to the “Spin Wheel” link which connects to the Rails backend and also starts the Raphael animation.
  • value += Math.floor(Math.random()*180) + 180; adds a random number of how many degrees to spin the wheel.
  • img.animate({rotation: value}, 2300, function() controls the animation of the image, in this case to rotate it a specific number of degrees over 2.3 seconds (2300 milliseconds).

I was very happy with using Raphael. I’m still working out how to get the animation smoother but Raphael was able to make it easy for me to simulate animation without having to use Flash.


inherited_resources is a Rails plugin that creates resource controllers. Instead of having to duplicate the standard, respond_to, format.html that is common in Rails applications, you just have to inherit the InherietedResources class and it will setup the 7 standard Rails actions for you. It includes a metric ton of hooks and ways to override it’s behavior. For example, I added a simple Content resource to MealEtte in order to post updates right to the site. Additionally, I wanted to use will_paginate to limit the amount of data on each page. My entire controller with an override for will_paginate looks like:

    class ContentsController  [:new, :create, :edit, :update, :destroy]
      def collection
        @contents ||= end_of_association_chain.paginate(:page =>; params[:page] || 1, :order => 'id DESC')

The collection method is my override and it tells inherited_resources to add the paginate method call when it’s finding a collections of resources (e.g. the index action in Rails). Other than that and my application specific authorization, all of the behavior is kept in inherited_resources so there’s a lot less code for me to maintain. One side benefit of this is that means there is a lot less code I have to test also, since inherited_resources itself tests it’s generated methods.


One common failure pattern in the past Rumbles has been teams putting off deployments until the very end and not being able to get their application running before time ran out. My goal was to deploy as soon and as often as possible; preferably as soon as I finished a new feature. In order to do that, I needed something faster than the standard 5-10 minute deployment process. This is where fast_remote_cache came in. Using fast_remote_cache I was able to deploy and have the server running the latest code in under a minute. This means I could do a small deployment in the amount of time it takes a user to load a new page. I’m going to be switching all my deployments to use fast_remote_cache soon, there’s no reason not too.

I ended up coming away from the 2009 Rails Rumble with a lot of experience about some newer tools and some great ideas on how to integrate them into older applications. If you haven’t ever done a code spike or any other rapid development on an application before, I’d highly recommend it just for the learning process. I’m planning to continue development on MealEtte to see how these tools perform during application maintenance.

Eric Davis

One comment

  1. Carlo Pecchia says:

    Nice post! A practical way to learn about some gems/libraries straight from their application “on the road”…

Comments are closed.