If I generate a scaffold called "product", what are the differences between the following when I use them in coding my app? @products, @product, @Product, @Products, Products, Product, product, and products (I’m pretty sure those aren’t all used, but it should at least give the idea of what I’m referring to).
I can’t seem to find a simple explanation of what each combination of @/capitalization/plurality means. Help would be greatly appreciated.
The only reserved word is capitalized
Productand this references the object model. For example to get all products and save it in the variable@productsyou would do:If you left off the
@sign off of ‘products’ then it would be saved only as a local variable and your view would not be able to access it.In this example
@productsand@productare variables you declare in the controller. You could just use: