Ruby on Rails: Beginning Rails - What Everything is For
(Page 4 of 4 )
Our Buddy the Controller
Our buddy the controller, as stated previously, is the foreman of your web application. He handles the requests sent from the user's web browser, such as a URL. It also directs people from page to page in your website. And lastly, the controller calls upon actions, then takes the result of that action and hands it on to a particular view.
The View...No, Not the Horrible Television Show
A view's function is pretty simple: display the results from an action. Keep in mind that there can be a plethora of views in a website, each triggered by a certain action. A good example of this is if you display a page asking a user for data through one action, then when the user enters that data, another action is called displaying a different view.
Do Your Thing, On the Runway
To handle the processing of data in your application, you need what is called a Model. Aside from looking really hot and being really dumb, models interact with actions and handle the data tasks for them.
Examples would be mathematical equations, checking to see whether a certain piece of data is in a database, copying information from one database to other databases, etc. The action gives data to the model, and the model returns some result to the action.
And there you have it folks...an explanation of what is known as the Model-View-Controller architecture.
Conclusion
We've covered a lot of ground in this tutorial. You learned how to build your first web app with Rails and how to set up your basic skeletal framework. Granted it was a cheesy static web page that was our result (whatchoo talk bout Willis?!?). But never fear. In our next exciting episode we will begin to work with more dynamic pages. You'll learn to do math, respond to user input and lots more. So be sure to come back often.
Till then...
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |