Directory Structure
Let’s take a quick glance at the files and directories that are included in a new Rails application.
Go to the terminal (to your right) and run the following command:
$ ls -la
Here is what you should see in the output:
File/Folder | Purpose |
---|---|
app/ | Contains the controllers, models, views, helpers, mailers, jobs, and assets for your application. You’ll focus mostly on this folder for the remainder of this guide. |
bin/ | Contains the rails script that starts your app and can contain other scripts you use to set up, update, deploy, or run your application. |
config/ | Contains configuration for your application’s routes, database, and more. This is covered in more detail in Configuring Rails Applications. |
config.ru | Rack configuration for Rack-based servers used to start the application. |
db/ | Contains your current database schema, as well as the database migrations. |
Dockerfile† | Configuration file for Docker. |
Gemfile | These files allow you to specify what gem dependencies are needed for your Rails application. These files are used by the Bundler gem. |
Gemfile.lock† | The lock file that ensures consistent gem versions across different environments. |
lib/ | Extended modules for your application. |
log/ | Application log files. |
public/ | Contains static files and compiled assets. When your app is running, this directory will be exposed as-is. |
Rakefile | This file locates and loads tasks that can be run from the command line. The task definitions are defined throughout the components of Rails. Rather than changing Rakefile , you should add your own tasks by adding files to the lib/tasks directory of your application. |
README.md | This is a brief instruction manual for your application. You should edit this file to tell others what your application does, how to set it up, and so on. |
script/ | Contains one-off or general purpose scripts and benchmarks. |
storage/ | Contains SQLite databases and Active Storage files for Disk Service. This is covered in Active Storage Overview. |
test/ | Unit tests, fixtures, and other test apparatus. These are covered in Testing Rails Applications. |
tmp/ | Temporary files (like cache and pid files). |
vendor/ | A place for all third-party code. In a typical Rails application this includes vendored gems. |
.dockerignore† | This file tells Docker which files it should not copy into the container. |
.gitattributes† | This file defines metadata for specific paths in a Git repository. This metadata can be used by Git and other tools to enhance their behavior. See the gitattributes documentation for more information. |
.git/† | Contains Git repository files. |
.github/† | Contains GitHub specific files. |
.gitignore† | This file tells Git which files (or patterns) it should ignore. See GitHub - Ignoring files for more information about ignoring files. |
.kamal/† | Contains Kamal secrets and deployment hooks. |
.rubocop.yml† | This file contains the configuration for RuboCop. |
.ruby-version | This file contains the default Ruby version. |
Files
Preparing Environment
- Preparing Ruby runtime