On creating a Rails application, the entire Rails directory structure is created. We will explain Rails 5 directory structure here.
The jtp directory (shown below) has a number of auto-generated files and folders that comprises the structure of Rails application.
We will explain the function of each of the files and folders present in the above directory.
File/Folder | Description |
---|---|
app | It works as the remainder of this directory. Basically it organizes our application component. It holds MVC. |
app/assets | This folder contains static files required for application’s front-end grouped into folders based on their type. |
app/controllers | All the controller files are stored here. A controller handles all the web requests from the user. |
app/helpers | It contains all the helper functions to assist MVC. |
app/mailers | It contains mail specific functions for the application. |
app/models | It contains the models and data stored in our application’s database. |
app/views | This folder contains the display templates to fill data in our application. |
bin | It basically contains Rails script that start your app. It can also contain other scripts use to setup, upgrade or run the app. |
config | It configures our application’s database, routes and more. |
db | It contains our current database schema and database migrations. |
lib | It contains extended module for your application. |
log | It contains application log files. |
public | It contains static files and compiled assets. This is the only folder seen by the world. |
test | It contains unit tests, other test apparatus and fixtures. |
tmp | It contains temporary files like cache and pid files. |
vendor | It contains all third-party code like vendor gems. |
Gemfile | Here all your app’s gem dependencies are declared. It is mandatory as it includes Rails core gems among other gems. |
Gemfile.lock | It holds gems dependency tree including all versions for the app. |
README.md | It is a brief instruction manual for your application. |
Rakefile | It locates and loads tasks that can be run from the command line. |
config.ru | Rack configuration for Rack based servers used to start the application. |
Leave a Reply