Forem

Cover image for Rails File Structure Overview
Kurt Bauer
Kurt Bauer

Posted on

4 1

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

KEAUNUUUU

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
  • CONFIG
    • 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
    • DEBUGGING!
    • for a prod env, you'll probably use outside service
  • PUBLIC
    • 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
  • VENDOR
    • mainly used to integrate client-side MVC framworks, such as Angular
  • GEMFILE
    • 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:
Helloquence

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more →

Top comments (0)

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay