In this post, we will discuss about Rails project directory structure.
Here is the directory structure:
<project-name>
…./<app>
………/<assets>
………/<controllers>
………/<helpers>
………/<mailers>
………/<models>
………/<views>
…./<bin>
…./<config>
…./<db>
…./<lib>
…./<log>
…./<public>
…./<test>
…./<tmp>
…./<vendor>
…./Gemfile
- app
This directory organizes all the components of the application. We will be writing most of our code under this directory.- assets
This folder contains images, stylesheets and javascripts. - controllers
This directory contains all controller classes for your application. Controllers are classes with methods that defines the application flow like urls, redirects etc. - helpers
Put all helper classes here. Helpers provides methods that can be used in views of your application. They are automatically included in views. - mailers
This folder contains classes that are used for sending emails. - models
This directory contains the classes that corresponds to your models. - views
All the view files (front end -> html, erb) are stored here.
- assets
- bin
This directory contains the bundle, rails and rake executables that are needed to execute various rails commands - config
This directory stores all the application configuration settings like database, routes, environment settings etc. - db
This directory contains the migration files that specifies the table structure. If you are using SQLite, its file will be stored here. - lib
Not used in most of the cases. If you want to write custom code for your application like helper for your controllers, you put them here. - log
All your application logs will be stored here. - public
This directory serve contents that are directory available to the world. For example, put a test.html here and it can be called like http://your_website/test.html - test
This directory is used for creating test cases for the application. - tmp
Here rails stores all temporary data like cache, session etc. - vendor
3rd party gems that are not handled by bundler are placed here. This directory should not be required in most of the cases. - Gemfile
This file contains all your required software (called gems) for your application. The bundle install command reads this file and downloads all the requirements and their dependencies.