1. 首先我们要在数据库里创建Order表创建表Sql如下:
create table orders (
id not null auto_increment,
name varchar(100) not null,
email varchar(255) not null,
address text not null,
pay_type char(10) not null,
primary key (id)
);
我们还要重新创建line_item表下面是Sql:
create table line_items (
id not null auto_increment,
product_id not null,
order_id not null,
quantity not null default 0,
unit_price decimal(10,2) not null,
constra fk_items_product foreign key (product_id) references products(id),
constra fk_items_order foreign key (order_id) references orders(id),
primary key (id)
);
在InstantRail里可以使用phpMyAdmin来执行Sql
运行命令行生成OrderModel如图:
现在点击CHECKOUT按钮会转到Rails个页面提示“Unknown action”下次我们实现这个功能
最新评论