I’ve been working with Ruby on Rails for a while now and I want to improve my coding style and learn proper conventions. I’m searching for some well-written Rails applications that I can study to see how experienced developers structure their code.
I’m particularly interested in projects that show good practices for things like:
Model organization and relationships
Controller design patterns
View helpers and partials
Testing approaches
File structure and naming conventions
Does anyone know of any open source Rails apps that are known for having clean, well-organized code? I’d really appreciate any suggestions you might have. Thanks in advance!
check out the discourse forum software on github - its a huge rails app but really well organized. they handle service objects well and keep controllers thin, which is solid. also, shopify’s liquid templating engine source has nice patterns to learn from.
I’d recommend looking at GitLab’s Community Edition repository. It’s massive but demonstrates excellent Rails architecture patterns, especially around service objects and complex model relationships. Their approach to feature flags and testing is particularly noteworthy. Another solid choice is Spree Commerce - while it’s an e-commerce platform, it showcases proper Rails engine structure and modular design principles. The codebase is clean and follows Rails conventions religiously. For something smaller but still comprehensive, Redmine project management tool offers good examples of traditional Rails patterns without being overwhelming. All three have extensive test suites that show proper testing methodologies.
Mastodon’s source code is excellent for studying Rails patterns, particularly their approach to background jobs with Sidekiq and complex model validations. I spent considerable time reviewing their ActivityPub implementation and learned a lot about structuring concerns properly. The way they handle internationalization and moderation features shows solid Rails architecture. For something more focused on e-commerce patterns, Solidus fork of Spree is worth examining - they’ve cleaned up a lot of the original codebase and their decorator pattern usage is textbook quality. One thing I noticed when studying these codebases is how they all prioritize keeping business logic out of controllers through service objects and form objects, which really helped me understand proper separation of concerns.
Forem (the platform that powers dev.to) deserves a mention here. Their Rails codebase demonstrates modern patterns particularly well, especially around background job processing and API design. What makes it valuable for learning is how they handle user-generated content at scale while maintaining readable code. The way they structure their concerns and decorators is quite educational. Another project worth examining is Lobsters, which is smaller than the previously mentioned options but shows excellent Rails fundamentals. Their voting system implementation and comment threading logic are particularly well-crafted examples of ActiveRecord associations done right. Both projects have active maintainers who follow current Rails best practices closely.
diaspora* is another gem worth checking out - their federation code might be complex but the basic rails structure is really solid. also basecamp’s hey email service has some public components that show dhh’s current thinking on rails patterns, tho not fully open sourced.