Agile web development with rails Reading Notes (3)

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.