In this post, we will discuss about Rails project directory structure.

Here is the directory structure:



















  • app
    This directory organizes all the components of the application. We will be writing most of our code under this directory.

    1. assets
      This folder contains images, stylesheets and javascripts.
    2. controllers
      This directory contains all controller classes for your application. Controllers are classes with methods that defines the application flow like urls, redirects etc.
    3. helpers
      Put all helper classes here. Helpers provides methods that can be used in views of your application. They are automatically included in views.
    4. mailers
      This folder contains classes that are used for sending emails.
    5. models
      This directory contains the classes that corresponds to your models.
      All the view files (front end -> html, erb) are stored here.
  • 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.

Creating your first rails project