0
0
Ruby on Railsframework~30 mins

First Rails application - Mini Project: Build & Apply

Choose your learning style9 modes available
First Rails application
📖 Scenario: You want to create a simple web app that shows a welcome message on the homepage. This is your first step into building with Rails, a popular web framework.
🎯 Goal: Build a basic Rails app with a homepage that displays the text "Welcome to My First Rails App!"
📋 What You'll Learn
Create a new Rails application named my_first_app
Generate a controller named home with an index action
Set the root route to the home#index action
Create a view for the index action that displays the welcome message
💡 Why This Matters
🌍 Real World
Creating a basic Rails app is the first step to building websites and web services that can handle user requests and show dynamic content.
💼 Career
Understanding how to set up a Rails app, create controllers, routes, and views is essential for web developer roles that use Ruby on Rails.
Progress0 / 4 steps
1
Create a new Rails application
Run the command rails new my_first_app in your terminal to create a new Rails application named my_first_app.
Ruby on Rails
Need a hint?

Use the rails new command followed by the app name my_first_app.

2
Generate a controller with an index action
Inside the my_first_app directory, run rails generate controller home index to create a controller named home with an index action.
Ruby on Rails
Need a hint?

Use rails generate controller home index to create the controller and action.

3
Set the root route to home#index
Open the file config/routes.rb and add the line root 'home#index' to set the homepage route to the index action of the home controller.
Ruby on Rails
Need a hint?

In config/routes.rb, add root 'home#index' inside the Rails.application.routes.draw do block.

4
Create the view with welcome message
Open the file app/views/home/index.html.erb and add the line <h1>Welcome to My First Rails App!</h1> to display the welcome message on the homepage.
Ruby on Rails
Need a hint?

Edit app/views/home/index.html.erb and add an <h1> tag with the welcome text.