Bringing It All Together
So far, we have seen how to use controllers, views, and models in a somewhat detached manner. In the previous chapter (Models, Databases, and Active Record), we manipulated data on our database. However, we didn’t see how to interact with the database data from our controller, much less how to load that database data into our view. In this chapter, we are going to see how everything comes together – that is, we’ll load a model from the controller and pass the model data to our view so that the end user will see data on the browser. We will also do the reverse, which is getting data from the user into our database, starting from the view and ending on the model. Furthermore, we will also learn the Rails way to perform these actions, as they are quite different from the way we would do these tasks in PHP.
With models, views, and controllers in mind, in this chapter, we will cover the following topics:
- Setting up our initial application...