Ruby on Rails Directory Structure

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.

Ruby On rails directory-structure 1

We will explain the function of each of the files and folders present in the above directory.

File/FolderDescription
appIt works as the remainder of this directory. Basically it organizes our application component. It holds MVC.
app/assetsThis folder contains static files required for application’s front-end grouped into folders based on their type.
app/controllersAll the controller files are stored here. A controller handles all the web requests from the user.
app/helpersIt contains all the helper functions to assist MVC.
app/mailersIt contains mail specific functions for the application.
app/modelsIt contains the models and data stored in our application’s database.
app/viewsThis folder contains the display templates to fill data in our application.
binIt basically contains Rails script that start your app. It can also contain other scripts use to setup, upgrade or run the app.
configIt configures our application’s database, routes and more.
dbIt contains our current database schema and database migrations.
libIt contains extended module for your application.
logIt contains application log files.
publicIt contains static files and compiled assets. This is the only folder seen by the world.
testIt contains unit tests, other test apparatus and fixtures.
tmpIt contains temporary files like cache and pid files.
vendorIt contains all third-party code like vendor gems.
GemfileHere all your app’s gem dependencies are declared. It is mandatory as it includes Rails core gems among other gems.
Gemfile.lockIt holds gems dependency tree including all versions for the app.
README.mdIt is a brief instruction manual for your application.
RakefileIt locates and loads tasks that can be run from the command line.
config.ruRack configuration for Rack based servers used to start the application.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *