Anatomy of a Rails Rumble Project
Clinton R. Dreisbach, Former Viget
Last weekend, two teams of Viget people (Hounds of Gore and Chewie & Han) competed in the 2010 Rails Rumble, and we all came out richer for it. My team built GitWrite and I wanted to share our experience.
The new jazz
We've been using Rails 3 at Viget for some projects and we're really enjoying it, so it was a no-brainer to use it for GitWrite. We also decided to finally move to Ruby 1.9.
Ruby 1.9 is dang impressive. It's fast, which any Ruby programmer knows is what we need more of. It's still no Haskell or even Python, but I'm not making a pot of coffee every time I'm running tests any more. We didn't run into any problems with libraries not being compatible with 1.9, either. After our experience, I'm recommending it for all future Ruby projects.
Rails 3 is solid and didn't give us any problems. We had some people on our team with no Rails 3, and they picked it right up. I don't have much to say about it that hasn't been said. Its quality explains itself.
OmniAuth is a freaking ninja sword for slicing through authentication nonsense. It takes something that normally takes about 2 hours too long and makes it take 5 minutes. If you need to maintain your own authentication system, I still recommend Devise, but if you can afford to let people log into your app via Google, Twitter, GitHub, or something else, grab OmniAuth.
One last new thing we used was my own static site generator, Howl. We wrote the whole thing during the Rumble based off some notes I had about my vision for the ideal simple blog generator. I'm happy with the result. It uses Mustache for its templating language, and I'm a little torn about that decision. Mustache is impressive, but the inability to send arguments along with template tags is frustrating, as well as the expectation that your template files will have
.mustache as their suffix. (I know you can change the latter, but it's not as clean as I'd like it.) Still, Mustache is cool and I'm glad I got to work with it.
Git hostin' ain't easy
I have even more respect for the guys at GitHub after trying my hand at hosting git repositories. Gitosis is the tool most people use, and I'm guessing it's part of the GitHub stack. I have to give Gitosis props: it's easy to install and just works out of the box. It was way smoother than I thought it would be.
On the second day of the Rumble, I circled back to Gitosis. Our Rails app was at the point that it now needed to write to repositories. (Our app is a blogging system that lets you edit through the web or through git.) Everything was nuts at this point. Gitosis seems to prefer bare repos, but we needed to check them out. We had permissions issues, as gitosis needs its own user and the Rails app couldn't write into the repos.
In the end, I think our final solution was good, but we have a few bugs. We realized that since the user checks out a repo, changes it, and pushes it, we should too. Our web app has repos for all its managed blogs checked out, and when you make a change through our interface, we commit it to our repo, and then push back to the master repo. The most difficult part of this is that blogs get generated on the Rails app's private repo, so when the user pushes, the Rails app has to pull before it gets the changes. If there's something to resolve, that can lock things up. We're working on it.
The state of Ruby libraries to access Git isn't wonderful. We tried Grit, which is what GitHub uses. Warning: do not try to learn this in a stressed out 48-hour period. It made some sense when it was editing existing repos, but I couldn't figure out how to create new repos. I know Grit has to be good, as it powers an amazing website, but it seemed like an unhelpful robot that only speaks 23rd century North Turko-Russian to me. I ended up using the Git gem by Scott Chacon instead. It's not actively maintained, but I found it to be simple to understand and only somewhat buggy. I patched exceptions with a very generous helping of
The last 20 minutes
Seriously, our app didn't work 20 minutes before launch. Git bugs were everywhere, interfaces were missing, and I was covered in spilled soda and crumbled potato chips. It was the life of kings, standing in the place where heroes are made among the bodies of the weak.
Our last commit slid into the repo right before they were locked down and the competition ended. The commit message?
d50098b rescue true