Open-source rails apps to study and learn from

May 31, 2010

If, like me, you learn best by studying other code here's five some open-source rails apps with something to teach. They're a great resource to study and improve your own code, or to use as the starting point for your own applications. All of these applications use Rails 2 but as they are open-source they are a great opportunity to get your feet wet in the Rails 3 world by helping to port them across.

Update: Thanks to the comments here and over on Hacker News, I've added two more applications and made some comments on the non-standard nature of the Loved by Less application code.

Gemcutter

A site familiar to all Ruby developers is Gemcutter - the recent replacement for the venerable Rubyforge. I wasn't aware that the source code of the site was open source until danieldon pointed it out to me, but you can study the code on github. The Gemcutter source is written in a very modern way featuring examples of using Cucumber for integration testing, a simple Rack middleware example and an interesting routes.rb file showing how to cleanly version an API.

Features

  • A very modern Rails application featuring the latest best practices.
  • Examples of metal and rack middleware.

Spot Us

Spot Us is a website that allows individuals to commission freelance journalists. It has many social-network type features which make the source code interesting reading.

Spot.us screenshot

The comprehensive test suite is written with rspec and the ruby-like templating system HAML is used for the views. It's also an example of how to use jQuery in a rails app instead of the default prototype through the use of the jrails plugin.

Features

  • Haml
  • rspec
  • jquery with the jrails plugin.

Loved by Less

Loved By Less is an open-source social network. I think many Rails freelancers have been asked to create a site with social network features - profiles, 'friending', photo sharing etc. Less Everything were no different and created this open-source platform to help ease the pain of getting started. The source code is available on github. It's unlikely that simply cloning the app will give you everything you need, but it's an amazing resource to read through and take the bits you need for your project.

The loved by less source code is starting to show it's age a bit, and does include some pretty extensive monkey patching which may confuse a newcomer. While I don't think this is bad in itself (it shows the flexibility of Ruby, and also the dangers of not following Rails conventions), it's something to be aware of. I think porting this to Rails 3 would give newcomers to Rails a great resource to learn from.

Features

  • Search with Thinking Sphinx
  • Flickr integration
  • Comprehensive email support
  • Paperclip for attachments

Saasy

If you're working on a Software as a Service application, take a look at Saasy . It's a template application designed to do billing and authentication tasks 'so you don't have to'.

Sassy screenshot

Studying the code base, you'll see examples of using SSL security and ActiveMerchant. I was also interested in the accounts model which uses the acts_as_state_machine plugin to simplify some of the logic.

Features

  • acts_as_state_machine
  • ActiveMerchant

Simply Agile

Simply Agile by Andrew Bruce is an open source agile software project management application. Think of a simple version of Pivotal Tracker. You can add story cards to a backlog, and then assign each card to a sprint. Each time a card is completed you can drag and drop it to the appropriate column in the Simply Agile task board. Andrew has a very dedicated approach to test-driven development and as a result the application is well covered by cucumber and rspec tests. The javascript in this application is written in an unobtrusive style and is a good example of using jQuery for "progressive enhancement". The app is fully functional in browsers without javascript, but where javascript is available so is the drag-and-drop interface.

Features

  • Cucumber integration tests
  • rspec coverage
  • Drag and drop interface powered by jQuery.

Typo

Typo is "the oldest and most powerful Ruby on Rails blogware" and is still under active development. While the 15 minute blog is still a fantastic demonstration of how powerful Rails is for rapid application development, anyone who has decided to take the project further and create their own fully-featured blog system will know how much extra work is needed. From comment systems, to anti-spam protection, restful routing to upload support there are many features that need to be added. Thankfully Typo has already implemented these and many other features, and the source code is available to help you learn how to do the same.

Features

  • rspec for testing
  • internationalisation support
  • email notification
  • admin and public-facing interfaces

Open Source Rails

Open source rails is a gallery of open-source rails projects. I selected this project for this list because although the code itself isn't well documented or tested, in many ways this is illustrates a great strenght of the Rails framework. It is a good project to study to realise how much can be achieved with a small amount of code and a handful of powerful plugins (not that I'd recommend starting your next Rails project without tests, of course!).

Features

  • OpenID integration
  • Paperclip for file uploads
  • A simple set of routes.

Conclusion

I hope you enjoyed this selection of Rails projects. This is far from a definitive list, and I encourage you to read some of the suggestions of other apps in the comments below and on the discussion over on Hacker News. With the upcoming Rails 3 release I think it's a good time to reflect how far the Rails framework has come, and also to remember to cater for people who are learning Rails for the first time - studying open-source code is a great way to learn.

Do you have a favourite open-source Rails project? Share it in the comments below.

Published