AI Reading
Quick summary of this article
Chapter 3: Creating Your First Rails Application
Creating a new Rails project is a single command. Rails will generate a complete project folder with all the files and folders you need, organised by convention. In this chapter you will create your first application, start the development server, and explore the project structure.
🚧 Creating a New Project
Open your terminal and run:
rails new myapp
Rails creates a folder called myapp containing the whole application, installs the required gems, and prepares the default database.
🚀 Starting the Server
Move into the project folder and start the built-in development server:
cd myapp
rails server
Now open your browser and visit http://localhost:3000. You should see the Rails welcome page. Congratulations, your first Rails application is running!
📁 Understanding the Project Structure
Inside the project folder you will see many files. Do not be overwhelmed; you only need a few of them every day:
- app/controllers/ – controller files that handle requests.
- app/models/ – model files that talk to the database.
- app/views/ – HTML templates (ERB files) for each action.
- config/routes.rb – the file where you define your URLs.
- db/migrate/ – database migrations that create and change tables.
- Gemfile – lists the Ruby gems your application uses.
# Key folders inside your Rails app
myapp/
app/
controllers/
models/
views/
config/
routes.rb
db/
migrate/
Gemfile
🏠 Practice Exercises
# 1. Create a new Rails project
rails new myapp
# 2. Move into it and start the server
cd myapp
rails server
# 3. Open http://localhost:3000 in your browser
If you see the Rails welcome page, everything is set up correctly. In the next chapter you will learn how routing connects URLs to controllers.
