- Read Tutorial
- Watch Guide Video
In this course, we've talked about the model, which is how we can work with the data in our application. We've talked about the controller, which is how we can manage that data. In this section, we're going to get into the View.
Rails is a MVC architecture, the V stands for the view. The view is what the user actually sees. As great as views are, they are usually one of the items that developers abuse the most. The reason for that is because usually, it's simply easier to put a lot of code in the views. This can make an application incredibly difficult to manage as it scales up.
We're going to talk about how we can manage our views effectively, not just to get the functionality we're looking for. The more important thing is how we can build them properly so they can be extended later when we need to make changes. We're going to talk about all kinds of things related to views.
This is going to be a pretty large section. We're going to talk about how to do things such as splitting up our code into partials so we can have isolated components of views that can be called from many different view files, that will allow us to write code once instead of having to copy and paste it throughout our application.
We're going to talk about how to customize and create additional layout files so far in our app we've only had a single layout file which is the master application layer file but rails is very flexible and allow us to have as many layouts as we want. This is a great thing to do whenever you have an application where you want one type of look and feel for one part of the site like the blog page but you want something that looks completely different for something else like our listing of portfolio items.
I'm going to show how we can create different layouts and then how our controllers can actually call those dynamically and decide when to use one layout file versus another. We're also going to talk about some very cool methods available in Rails that allow us to generate HTML code dynamically so we can focus on writing more ruby code and less HTML code, that's going to make our code look more elegant and easier to customize in the future.
So let's dive into the videos.