Models, Views, and Controllers
Understand the key components of a Rails app and how they interact.
Models, Views, and Controllers is a free Ruby Academy lesson on CoddyKit — lesson 3 of 3. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Ruby Academy learning path, one of 3 lessons in the course, and your progress syncs across the web and the CoddyKit app.
1
Models, Views, and Controllers
Rails applications follow the Model-View-Controller (MVC) pattern.
In this lesson, you will learn how these components interact in a Rails app.

2
What is a Model?
Models handle the data and business logic of your application.
They interact with the database using Active Record.
3
Creating a New Model
Use the following command to generate a model in Rails.
rails generate model User name:string email:string4
What is a View?
Views are responsible for displaying the user interface.
They use embedded Ruby (ERB) to render dynamic content.
5
Creating a View
Create an HTML file inside the app/views folder.
app/views/users/index.html.erb6
What is a Controller?
Controllers handle user requests and send data to views.
They receive input, process it, and pass the output to the view.
7
Generating a Controller
Use the following command to generate a new controller.
rails generate controller Users index show8
9
Understanding MVC Flow
When a user makes a request, the flow is as follows:
- The controller receives the request.
- The model fetches or updates data.
- The view renders the response.
10
Congratulations!
You have learned the basics of Models, Views, and Controllers in Rails.
This concludes the Ruby on Rails Basics section.

Frequently asked questions
Is the “Models, Views, and Controllers” lesson free?
Yes — the full text of “Models, Views, and Controllers” is free to read here on the web, and the Ruby Academy course includes 3 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Ruby Academy course, upgrade to CoddyKit PRO.
What will I learn in “Models, Views, and Controllers”?
Understand the key components of a Rails app and how they interact. You practise Ruby Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Ruby Academy?
No prior experience is required. Ruby Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 3, so you can start here or from the beginning and move at your own pace.
How long does the “Models, Views, and Controllers” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Ruby Academy lesson?
Yes. Every Ruby Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- What is Ruby on Rails?
- Setting Up a Rails Project
- Models, Views, and Controllers