Skip to content

Instantly share code, notes, and snippets.

@sent-hil
Created March 21, 2012 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sent-hil/2146566 to your computer and use it in GitHub Desktop.
Save sent-hil/2146566 to your computer and use it in GitHub Desktop.
Rearrangement of Rails folder structure based on 'Architecture the Lost Years'
# Rearrangement of Rails folder structure based on Robert Martins' Keynote: Architecture the Lost Years.
# This structure was meant to say 'I am a web app that does x and y and only incidentally uses Rails'.
# I'm interested in knowing if:
# 1. Is this viable in the long run?
# 2. Can you tell what the app does?
|── Gemfile
├── Gemfile.lock
├── Readme
│── authentication
│   ├── sessions_controller.rb
│   ├── user.rb
│   └── users_controller.rb
│── repo_statistics
│   ├── repo.rb
│   └── repo_controller.rb
├── rails
│   ├── boot.rb
│   ├── log
│   │   ├── development.log
│   │   └── production.log
│   └── rack.ru
├── spec
│   └── acceptance
│   └── authentication_spec.rb
└── vendor
@sent-hil
Copy link
Author

original Rails structure

├── Gemfile
├── Gemfile.lock
├── README
├── app
│   ├── controllers
│   │   └── users_controller.rb
│   │   └── sessions_controller.rb
│   ├── models
│   │   └── user.rb
│   │   └── repo.rb
├── config
│   ├── application.rb
│   ├── boot.rb
│   ├── environment.rb
├── config.ru
├── log
│   └── development.log
├── script
│   └── rails
├── test
│   ├── functional
│   │   └── users_controller_test.rb
│   ├── integration
│   ├── test_helper.rb
│   └── unit
│       └── users_test.rb
├── tmp
│   └── cache
│       └── assets
└── vendor

@DivineDominion
Copy link

I like the typical gem-compatible folder structure for a model:

├── Gemfile
├── lib/
│   ├── appname.rb
│   ├── appname/
│   │   ├── user.rb
│   │   ├── user_authenticator.rb  # Service object to fetch a User object
│   │   ├── repo.rb
├── spec/

Uncle Bob said himself you could bundle this up as a gem and plug it in somewhere else, i.e. your Rails app.

Without a frontend, though, a service object like the UserAuthenticator won't be used anywhere but in the tests. I haven't decided whether that might be a problem, yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment