Starting from chapter 1, it has gradually become more difficult. In many cases, due to poor syntax, errors may occur during the debugging process. Pay attention to the following points:
CSS should be used as much as possible on webpages, and Div should be used more to facilitate customization and adjustment of views.
Add <% = @ content_for_layout %> as the placeholder symbol in page decoration.
During cookie debugging, pay attention to clearing sessions. During debugging, the content in the session is incorrect, which leads to incorrect display.ProgramLogic error. After the cookie is cleared, the program is normal.
The newly created model and manually created class must be defined in applicationcontroller, in the format of model: cart.
If a private method exists in the class, pay attention to the order of the Public method to avoid this. The public method is changed to the private method.
By default, the last statement in a function is the return value of the function. For example:
Def Self. for_product (product)
Item = Self. New
Item. Quantity = 1
Item. Product = Product
Item. unit_price = Product. Price
Item
End
When I got it, I didn't write the last item, and the results were all wrong.
Because I did not carefully read Ruby syntax-related books, some syntaxes still seem odd and require constant familiarity, such as the following syntax: @ Items<Lineitem. for_product (product)
Note that the <%-%> syntax will cancel the line feed followed by the output.