首页 > 其他 > 详细

【BUG】关于rails4 数据迁移遇到的问题

时间:2015-03-27 21:40:25      阅读:192      评论:0      收藏:0      [点我收藏+]

按照 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 ,总算搞定了。

【BUG】关于rails4 数据迁移遇到的问题

原文:http://www.cnblogs.com/jqiong/p/4372657.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!