按照 http://www.cnblogs.com/dahuzizyd/archive/2007/04/13/Ruby_On_Rails_windows_InstantRails_begin_5.html
进行数据迁移发生问题,因这篇文章用的是旧版本的rails所以只好查了一个下午。
首先是建立项目相关的数据库
在自已的MYSQL上建了这三个数据库(depot开头的)
这是建表话句,与原博客相比做了一些简化
drop table if exists products; create table products ( id int not null auto_increment, title varchar(100) not null, description text not null, image_url varchar(200) not null, price decimal(10,2) not null, primary key(id) );
在项目填入MYSQL相关信息
default: &default adapter: mysql2 encoding: utf8 pool: 5 username: root password: toor host: localhost
但一用迁移命令就出错后来发现没有用管理员权限运行CMD
之后采用新命令(关于命请把MODEL的首字母大写)
rails generate scaffold Product title:string description:text image_url:string price:decimal
迁移成功,悲催的事情又发生了
一旦打开页面,又开始报错
Migrations are pending; run ‘rake db:migrate RAILS_ENV=development‘ to resolve this issue.
多谢几位RUBY CHINA上的大神
删除DB下的migrate文件夹即可
原因:
而后在浏览器中输入 http://localhost:3000/products/new ,总算搞定了。
原文:http://www.cnblogs.com/jqiong/p/4372657.html