Locked lesson.
About this lesson
Exercise files
Download this lesson’s exercise file.
Understanding The Ruby on Rails MVC Architecture.docx59 KB
Quick reference
Understanding The Ruby on Rails MVC Architecture
Ruby on Rails uses MVC Architecture; which stands for Model, View, and Controller.
When to use
MVC is a popular architecture used by many web development tools such as Django, Node, Rails, and many others.
Instructions
MVC architecture is a way to separate out database stuff, from web pages, from complicated computer code. It makes developing web sites easier for us and allows us to create web sites that are easier to use.
The MVC architecture shows up within the Ruby on Rails directory structure. You'll see directories that correspond with Models (databases), Views (web pages), and Controllers (controllers) within your workspace directory.
MVC is a concept. You don't need to understand too much about it at this point, just be aware that it exists.
Hints & tips
- MVC stands for Model, View, and Controller
- Model deals with database stuff
- View deals with Web pages (we "view" a web page)
- Controllers deal with complicated computer code behind the scenes
- Controllers help Databases and Views interact
- Think of Controllers as "the brains" of your app
- 00:00 Okay.
- 00:05 Before we dive in here and start going through all these different directories
- 00:09 and files and things, I wanna take a quick step back and
- 00:12 talk about a broad concept that's kind of important moving forward.
- 00:15 And that concept is MVC.
- 00:18 MVC stands for model, view, and controller.
- 00:23 And it's a basic web development concept that is good for
- 00:27 you to understand moving forward.
- 00:29 It's gonna help you figure out what all these different directories are for and
- 00:33 they'll help you become a better developer.
- 00:35 What is MVC?
- 00:36 If we go to Google and head over Wikipedia,
- 00:39 there's a nice little article you can read if you're interested.
- 00:43 What we really want to do is just look at this picture right here.
- 00:47 The idea of an MVC is basically these three things.
- 00:50 We can ignore this user and just look at this.
- 00:53 M stands for model; that's database stuff.
- 00:56 Anytime your app uses a database, you're going to be dealing with model.
- 01:01 Views, those are webpages.
- 01:03 Anytime a user views a webpage that falls under view.
- 01:07 Controller is the brains behind the scene, it connects models and views.
- 01:12 It allows you to do programmatic things behind the scenes using computer code.
- 01:17 And it's a way to abstract out all your computer code from your actual view and
- 01:21 from your actual model.
- 01:23 And keeping these three things separate is very important.
- 01:27 It makes everybody's lives easier going forward.
- 01:30 Not just yours as the developer, but it makes better websites, too.
- 01:35 Now Ruby on Rails throughout this course, obviously.
- 01:38 But in the future, you may want to use Python and Jango, JavaScript and Node,
- 01:43 whatever, and a lot of these frameworks use this model view controller concept.
- 01:48 So, wrapping your brain around it right now is a good idea.
- 01:51 You don't have to know in great detail what this is all about,
- 01:55 I just want you to be aware that it exists.
- 01:59 These three things they're all separate, it's a way to keep things abstract out and
- 02:02 keep things straight.
- 02:03 Now it's important to us because if look through all these directories,
- 02:08 if we click on some of these and expand,
- 02:11 you can see it's pretty easy to get overwhelmed by all this stuff.
- 02:15 But if we look at all this through the eyes of an MVC architecture,
- 02:19 it becomes a lot easier to keep it all straight,
- 02:21 cuz all of these things are gonna fall under different sections of MVC.
- 02:26 Like you see right here, database config, that's gonna controller, your app.
- 02:30 You see this is views, that's gonna be obviously views.
- 02:33 So, we'll get into all this in the next video.
- 02:36 Right now, I just want you to be aware of this MVC thing.
- 02:40 If you wanna read more about it, you can here at Wikipedia.
- 02:42 It's not that important that you do that, but if you're interested,
- 02:46 it's something to keep in mind and you're definitely going to use it.
- 02:49 At least, conceptually, in your brain, moving forward, and it's
- 02:54 very important for modern web development, this idea of model-view-controller.
- 02:58 You'll run up against it many, many times throughout your career, so
- 03:01 just be aware of that.
- 03:02 Like I said, in the next video, we're gonna dive into all this and
- 03:06 we're gonna see how all these files and
- 03:08 directories relate to the model-view-controller system.
- 03:11 But for right now, just understand that Rails is a model-view-controller system.
- 03:16 And I think that's all for this video.
Lesson notes are only available for subscribers.