rubyonrails:Ruby on rails开发从头来(windows)(十一)-订单(Order)

  在上次内容里我们实现了清空购物车和金额格式化处理这次实现订单模块

  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”下次我们实现这个功能



Tags:  rubyonrails安装 rubyforrails rubyrails rubyonrails

延伸阅读

最新评论

发表评论