DEV Community

Cover image for Rails File Structure Overview
Kurt Bauer
Kurt Bauer

Posted on


Rails File Structure Overview

The Gist

This is a quick read, more so a reference guide as to what those files in your new rails app are about


If you're like me and just are getting to know RBENV after uninstalling rvm then you'd want to start with:

gem install rails

Then you get a long list of gems that installed successfully

After which you hit your keyboard with the good ol'

rails new cool-project

Once you navigate over to your code editor of choice you would see the following files, let's take a look at what each one does in general.

File Structure

  • APP
    • contains models, views, controllers
    • core functions found here
    • only place where you can make changes and not have to restart your rails server
    • location of Non-Ruby files such as, but not limited to
      • JS, CSS, images, fonts, more assets such as these
  • BIN
    • built in rails tasks. You shouldn't be worrying about this folder way too much
    • Settings that control behavior:
    • Environment Settings
    • modules that initialize when app starts
    • app settings
    • data base settings
    • app routes
    • secret key base
  • DB
    • schema.rb file
    • this lists:
    • database tables
    • columns
    • column associated data types
    • seeds.rb file
    • enables you to create data to be used in the app
    • can quickly integrate data into the app
  • LIB
    • houses custom rake tasks
    • example case: can run in the background, make calls to an external API, and sync returned data in app's db.
  • LOG
    • application logs
    • for a prod env, you'll probably use outside service
    • Custom error pages
    • robots.txt
    • controls how search engines index the app
  • SPEC/test (will mostly use RSPEC)
    • test suite:
    • specs, factories, test helpers, test configuration
  • TMP
    • for temporary files, never really had to deal with this
    • mainly used to integrate client-side MVC framworks, such as Angular
    • all of your gems from your project
    • outside libraries used in the app
    • after changing gemfile, rerun BUNDLE
    • calls in code dependencies of application
    • (Gems are ruby files that extend functions of app)
  • GEMFILE.lock
    • don't edit!
    • dependencies and associated versions
  • README.rdoc
    • for your to document details of app
    • instructions for other devs

Hopefully this helps you the next time your trying to remember what folder to look into to fix a bug 🐛

Photo Credit:

Top comments (0)

50 CLI Tools You Can't Live Without

>> Check out this classic DEV post <<