0
0
Ruby on Railsframework~30 mins

Rails new project generation - Mini Project: Build & Apply

Choose your learning style9 modes available
Rails New Project Generation
📖 Scenario: You want to create a new web application using Ruby on Rails. This app will help you manage a simple blog with posts and comments.
🎯 Goal: Learn how to generate a new Rails project with the correct setup and basic configuration.
📋 What You'll Learn
Create a new Rails project named blog_app
Set the database to postgresql
Add a configuration variable for the Rails environment
Generate a scaffold for Post with title:string and body:text
Run the database migration to create the posts table
💡 Why This Matters
🌍 Real World
Creating a new Rails project is the first step in building web applications like blogs, e-commerce sites, or social platforms.
💼 Career
Understanding Rails project setup is essential for backend web developers working with Ruby on Rails frameworks.
Progress0 / 4 steps
1
Create a new Rails project
Run the command to create a new Rails project called blog_app using the postgresql database.
Ruby on Rails
Need a hint?

Use rails new blog_app -d postgresql to create the project with PostgreSQL as the database.

2
Set Rails environment variable
Inside the blog_app directory, create a file called .env and add a line to set the Rails environment variable RAILS_ENV to development.
Ruby on Rails
Need a hint?

Create a file named .env and write RAILS_ENV=development inside it.

3
Generate Post scaffold
Run the Rails generator command to create a scaffold for Post with a title of type string and a body of type text.
Ruby on Rails
Need a hint?

Use rails generate scaffold Post title:string body:text to create the Post scaffold.

4
Run database migration
Run the command to migrate the database and create the posts table based on the scaffold.
Ruby on Rails
Need a hint?

Run rails db:migrate to apply the database changes.