Open-source rails apps to study and learn from
If, like me, you learn best by studying other code here's
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.
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.
- A very modern Rails application featuring the latest best practices.
- Examples of metal and rack middleware.
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.
- 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.
- Search with Thinking Sphinx
- Flickr integration
- Comprehensive email support
- Paperclip for attachments
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'.
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.
- Cucumber integration tests
- rspec coverage
- Drag and drop interface powered by jQuery.
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.
- 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!).
- OpenID integration
- Paperclip for file uploads
- A simple set of routes.
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.