Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Introduction to Ruby on Rails 7!
You have completed Introduction to Ruby on Rails 7!
Preview
Meet the heart of Rails: the Model-View-Controller pattern. Learn how MVC streamlines your code, keeps things organized, and paves the way for robust, scalable applications.
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
Okay, so the first thing that we're going
to do is CD into the Rails project that we
0:00
just created.
0:05
So do CD Link Tree Clone.
0:06
And then we're going
to open it in VS code.
0:09
So if you're in command prompt and you
have VS code, you can just do code dot.
0:13
Then we'll open it in VS code.
0:17
And as you can see,
the folder opened in VS code.
0:18
VS Code is my favorite code editor and
I believe you should use it.
0:22
If you use it, our projects will be alike
and you won't get any errors with your
0:26
code editor and it'll just be
a way simpler process for you.
0:30
But in this video we're going to
learn about the MVC architecture.
0:33
Rails is an MVC framework.
0:37
What that means is Model View controller.
0:38
Now, as you can see, lots of files and
folders were generated.
0:41
Don't be scared or daunted.
0:44
This is okay.
0:46
We're mainly going to be
working in the model view and
0:47
controller because Rails
is an MVC framework.
0:50
Now let's go into app and here is
where the Model View Controller is.
0:53
So as you can see, controllers.
0:57
This is the folder for
all of our controllers.
0:59
So, we can have like
an application controller.
1:01
If we were making YouTube,
we might have like a videos controller.
1:03
But we're not making YouTube,
we're making link Tree.
1:05
So that's the Controller's folder.
1:08
Then you also have the Models folder.
1:11
If we were making YouTube,
we would have like a video model.
1:15
And then we have the Views folder.
1:18
This is where our actual web page is.
1:20
So like the HTML CSS in this case,
in Ruby on Rails we use html.erb.
1:22
Anyway, let's learn about MVC.
1:27
So we have controllers, models, and views.
1:29
The View is the end product.
1:33
This is the web page that you're served.
1:35
The model is the thing that
brings the web page to you.
1:37
It's the thing that
houses all of the data.
1:40
So let's imagine a video.
1:42
The video model has lots of data.
1:43
It has the title, has the description,
it has the actual video itself.
1:45
The new controller is the thing that
actually controls all of this and
1:48
sends it to you.
1:52
So, let's say from
the views from the webpage,
1:53
you send an action to the controller
to create a new video.
1:56
This is the thing that actually
creates a new controller and
1:59
adds it to the database.
2:02
So that's the Model vView
controller architecture.
2:03
We're gonna talk about it
more in the future, so
2:05
don't be worried if you
don't understand it now.
2:07
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up