Real World Rails applications and their open source codebases for developers to learn from
This project brings 100+ (and growing) active, open source Rails apps and engines together in one repository, making it easier for developers to download the collected codebases and learn from Rails apps written by experienced developers. Reading open source code can be an invaluable learning aid. You’ll find the source code in the apps/
and engines/
subdirectories.
Real World Rails was begun to help teach newer developers and to research and write about Rails development practices:
- Find example usage of a method you’re unsure of
- Learn how other developers use a gem you’d like to use
- Discover how to write tests
- See how Rails engines are built
- …and much, much more.
Ensure you have git-lfs installed: https://git-lfs.com
# Clone this git repo:
git clone git@github.com:eliotsykes/real-world-rails.git
cd real-world-rails/
# The Rails apps are linked to as git submodules.
GIT_LFS_SKIP_SMUDGE=1 git submodule update --init --single-branch --jobs 4
# To run the `bin/rwr` inspectors, install gems:
bundle install
echo "All done! Why not run some inspections? Run bin/rwr"
Pull the latest commits from this repo and update submodules:
git pull
GIT_LFS_SKIP_SMUDGE=1 git submodule update
- Real World Sinatra https://github.com/jeromedalbert/real-world-sinatra
- Real World Ember https://github.com/eliotsykes/real-world-ember
- Real World Ruby Apps https://github.com/jeromedalbert/real-world-ruby-apps
- Real World React https://github.com/jeromedalbert/real-world-react
- Real World Django https://github.com/ckrybus/real-world-django
This will find most, but not all job subclasses (requires ag):
# Outputs jobs source in terminal
ag --ruby '< [A-Za-z]+Job\b'
# Open each job in your editor (e.g. atom)
ag --ruby -l '< [A-Za-z]+Job\b' | xargs atom
(used to research Real World Rails Background Jobs)
Interested in seeing how your fellow developers name their models? Run:
bin/rwr models | sort -f | uniq -c | sort -k 1nr -k 2f
bin/rwr constants
(this helped when researching Magic Numbers in Ruby & How You Make Them Disappear)
See the file path and source of every view spec in every app:
bin/rwr view-specs
(this will show 250+ view specs, see them in The Big List of View Specs)
See just the model method names and file paths:
bin/rwr model-method-names
See the model method source and file paths:
bin/rwr model-methods
find apps/ -name Gemfile.lock | xargs grep GEM_NAME_GOES_HERE
# e.g. Find all projects using doorkeeper gem
find apps/ -name Gemfile.lock | xargs grep doorkeeper
bin/rwr shared-view-dirs
bin/rwr view-naming
# Outputs contents from all Procfiles
find apps/ -name 'Procfile*' | xargs cat
Prefix the bin/rwr
command with the FILES_PATTERN
environment variable:
FILES_PATTERN=~/dev/my-rails-app/**/*.rb bin/rwr
Prefix bin/rwr
with the SOURCE_OUTPUT_FORMAT
environment variable:
SOURCE_OUTPUT_FORMAT=markdown bin/rwr view-specs
Given a GitHub repo for a Rails app githubuser/foo
:
# Inside real-world-rails root:
# Replace <DEFAULT_BRANCH> with correct branch (probably 'main').
GIT_LFS_SKIP_SMUDGE=1 git submodule add -b <DEFAULT_BRANCH> git@github.com:githubuser/foo.git apps/foo
Only use this if a previously public repo has been removed:
# Remove the submodule from .git/config
git submodule deinit -f path/to/submodule
# Remove the submodule from .git/modules
rm -rf .git/modules/path/to/submodule
# Remove from .gitmodules and remove the submodule directory
git rm -f path/to/submodule
The inspectors are responsible for the analysis of the Rails apps.
Review the existing inspectors if you're looking for some info on how to write a new one, and see these API docs: