Ruby on Rails development from scratch (Windows) (11)-Orders (order)

Source: Internet
Author: User
Tags command line ruby on rails

In the last content, we realized the format of emptying the shopping cart and the amount. The module that implements the order this time.

1. First, we create the order table in the database, and create the SQL of the table as follows:

CREATE TABLE orders (
ID int not NULL auto_increment,
name varchar (MB) NOT NULL,
email varchar (255) NOT NULL, Address
text is not NULL,
Pay_type char (a) not NULL,
primary key (ID)
);

We'll also re-create the Line_item table, and here's the SQL:

CREATE TABLE Line_items (
ID int not NULL auto_increment,
product_id int not NULL,
order_id Int. not NULL,
 quantity int NOT NULL default 0,
unit_price decimal (10,2) NOT NULL,
constraint fk_items_product foreign key ( PRODUCT_ID) references products (ID),
constraint Fk_items_order foreign key (order_id) references orders (ID),
primary KEY (ID)
);

In Instantrail, you can use phpMyAdmin to execute SQL.

Run the command line, generate the order model, as shown in figure:

Related Article

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.