Skip to the workspace
Pebellslearn by building
Meet Rails  ›  Lesson

Creating an App and Its Folders

Create an App 15 minrails new builds a complete, runnable app whose folders each have one job: app for your code, config for settings, db for the schema, bin for commands, public for static files and the Gemfile for dependencies.

ruby on rails / Creating an App and Its Folders

Explore each scene at your own pace.

01 · The rule

The rule

Creating an App and Its Folders

One command gives you a working web app: a server that starts, a database that connects and a welcome page. The command is rails new. What it leaves behind is a set of folders, and knowing their jobs is half of knowing Rails.

The rule

Your code in app, settings in config, data shape in db.

rails new bookclub
cd bookclub
bin/rails server

rails new creates the project, writes a Gemfile and runs bundle install. bin/rails server starts the Puma web server at http://localhost:3000. The defaults in Rails 8 are SQLite for the database, Hotwire for interactivity and Importmap for JavaScript, so there is no build step to set up. Flags change the defaults, for example rails new bookclub --database=postgresql.

The folders that matter first:

Path Job
app/ Your code: models, views, controllers, helpers, javascript, assets, jobs, mailers
config/ Settings: routes.rb, database.yml, environments/, credentials
db/ migrate/ (schema changes), schema.rb (current shape), seeds.rb (starter data)
bin/ Scripts you run: bin/rails, bin/setup, bin/dev
public/ Static files served as-is, such as 404.html and robots.txt
Gemfile The gems (libraries) the app depends on; Gemfile.lock pins exact versions

You will also see test/ for tests, log/ for log files and tmp/ for caches.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.