Introduction
When we use the Rails helper script to create our application, it makes the entire directory structure for the application. Rails know where to find things it needs within this structure, so you don't have to provide any input. Every Rails project will have the same directory structure and naming conventions except for minor changes between releases. This consistency gives you a tremendous advantage as you can quickly move between projects without relearning the directory structure again. You can make a directory structure using a simple helper command rails demo.
Directory Structure
We can see the directory structure of ruby on rails as below.
Given below are the function of some of the files/folders mentioned above:
File or Folder | Description |
app |
It works like the remainder of this directory. It organizes our application component and holds MVC. |
app/assets |
This folder contains static files required for the application's front-end grouped into folders based on their type. |
app/controllers |
It contains all the controller files. A controller handles all the web-related requests from the user. |
app/helpers |
It includes all the helper functions to assist the MVC. |
app/mailers |
It includes email-specific functions for the application. |
app/models |
It includes the models and data stored in our application's database. |
app/views |
This folder holds the display templates to fill data in our application. |
bin |
It contains a Rails script that starts your app. It can also include other scripts used to set up, upgrade or run the app. |
config |
It contains information configuring our application's database, routes, and more. |
db |
It includes our current database schema and database migrations. |
lib |
It includes an extended module for your application. |
log |
It has application log files. |
public |
It contains static files and compiled assets. It is the only folder seen by the outer world. |
test |
It includes unit tests, other test apparatus, and fixtures. |
tmp |
It includes temporary files like cache and pid files. |
vendor |
It includes all third-party code like vendor gems. |
Gemfile |
Here all your applications’ gem dependencies are declared. It is a mandatory file as it includes Rails core gems, among other gems. |
Gemfile.lock |
It holds a gems dependency tree, including all versions for the app. |
README.md |
It is a brief instruction manual of your application. |
Rakefile |
It finds and loads tasks that can run from the command line. |
config.ru |
Rack configuration for Rack-based servers used to start the application. |