|
| 1 | +--- |
| 2 | +type: lesson |
| 3 | +title: Creating your first Rails app |
| 4 | +editor: false |
| 5 | +custom: |
| 6 | + shell: |
| 7 | + workdir: "/workspace/store" |
| 8 | +--- |
| 9 | + |
| 10 | +Directory Structure |
| 11 | +------------------- |
| 12 | + |
| 13 | +Let's take a quick glance at the files and directories that are included in a |
| 14 | +new Rails application. |
| 15 | + |
| 16 | +Go to the terminal (to your right) and run the following command: |
| 17 | + |
| 18 | +```bash |
| 19 | +$ ls -la |
| 20 | +``` |
| 21 | + |
| 22 | +Here is what you should see in the output: |
| 23 | + |
| 24 | +:::info |
| 25 | +Items marks with † are related to local development environment, deployment and CI, and, thus, missing in the web version. |
| 26 | +::: |
| 27 | + |
| 28 | +| File/Folder | Purpose | |
| 29 | +|------------|---------| |
| 30 | +| 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.** | |
| 31 | +| 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. | |
| 32 | +| config/ | Contains configuration for your application's routes, database, and more. This is covered in more detail in [Configuring Rails Applications](configuring.html). | |
| 33 | +| config.ru | [Rack](https://rack.github.io) configuration for Rack-based servers used to start the application. | |
| 34 | +| db/ | Contains your current database schema, as well as the database migrations. | |
| 35 | +| Dockerfile† | Configuration file for Docker. | |
| 36 | +| Gemfile | These files allow you to specify what gem dependencies are needed for your Rails application. These files are used by the [Bundler](https://bundler.io) gem. | |
| 37 | +| Gemfile.lock† | The lock file that ensures consistent gem versions across different environments. | |
| 38 | +| lib/ | Extended modules for your application. | |
| 39 | +| log/ | Application log files. | |
| 40 | +| public/ | Contains static files and compiled assets. When your app is running, this directory will be exposed as-is. | |
| 41 | +| 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. | |
| 42 | +| 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. | |
| 43 | +| script/ | Contains one-off or general purpose [scripts](https://github.com/rails/rails/blob/main/railties/lib/rails/generators/rails/script/USAGE) and [benchmarks](https://github.com/rails/rails/blob/main/railties/lib/rails/generators/rails/benchmark/USAGE). | |
| 44 | +| storage/ | Contains SQLite databases and Active Storage files for Disk Service. This is covered in [Active Storage Overview](active_storage_overview.html). | |
| 45 | +| test/ | Unit tests, fixtures, and other test apparatus. These are covered in [Testing Rails Applications](testing.html). | |
| 46 | +| tmp/ | Temporary files (like cache and pid files). | |
| 47 | +| vendor/ | A place for all third-party code. In a typical Rails application this includes vendored gems. | |
| 48 | +| .dockerignore† | This file tells Docker which files it should not copy into the container. | |
| 49 | +| .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](https://git-scm.com/docs/gitattributes) for more information. | |
| 50 | +| .git/† | Contains Git repository files. | |
| 51 | +| .github/† | Contains GitHub specific files. | |
| 52 | +| .gitignore† | This file tells Git which files (or patterns) it should ignore. See [GitHub - Ignoring files](https://help.github.com/articles/ignoring-files) for more information about ignoring files. | |
| 53 | +| .kamal/† | Contains Kamal secrets and deployment hooks. | |
| 54 | +| .rubocop.yml† | This file contains the configuration for RuboCop. | |
| 55 | +| .ruby-version | This file contains the default Ruby version. | |
0 commit comments