Understanding the MVC(Model View Controller) Architecture in Rails Applications
Ruby on Rails Tutorial — Part 2
Now, before we delve into building a ruby on rails application, I just wanted to get the basics out of the way.
Rails is a Ruby framework that is used to build database — backed full stack applications for the web. In order to do so, it follows a certain pattern that handles different aspects of the application. This pattern is what we call the MVC — Model View Controller
Understanding the MVC will help to understand what is happening especially if you’re building a web application in rails (or any other framework) for the first time.
So, here is a very basic breakdown of the different aspects of the MVC architecture
1.0 Model
- Models are what interact with the database. The model basically defines the structure of the database.
- Alternatively, think of it as basically databases
2.0 View
- The view is the output that is rendered onto the screen. Think of it as the HTML output that the user sees.
3.0 Controller
- The controller is the middleman between the model and the views. It takes the information from a request that it has received, and it will then take the model data and render it as a view for the user. Depending on the request received, it will conduct CRUD(Create, Read, Update and Delete) operations.
p/s: Dont worry about the CRUD for now. We will come to that later!
#Ruby #RubyOnRails