I think the most useful concept I learned this week was the connection between Controller and View, specifically with regards to the index and show actions.
With the index action, we are always dealing with all entries that have been made, so the variable is plural. For instance, we would declare under the product controller:
In turn, when the index action is called, it renders the
views/XXX/index.html.erb page. In this page, in order to retreive information for the products, we would have to call the
Similarly, under the show action, we are dealing with information for a specific occurance of a product, and thus the word "product" should be singular.
And in the
views/products/show.html.erb file, we call the singular @product variable which has already been defined in the controller:
This distinction really helped me to code better in the view files to make sure I'm getting the correct variables.