Rails 3.1 branch * work in progress *

Don't merge this just yet.

@henare could you check this branch out please?

I'm getting one failing test remaining which I can't figure out. Could you please see if you're getting it too and see if you can see what's going on.

Thanks!