商讯信箱
用户名:
@
vip.it168.com
free.it168.com
udc.it168.com
staff.it168.com
it168.com
密 码:
注册
|
忘记密码
登录
个人用户
经销商
用户名:
密 码:
注册
|
忘记密码
验证码:
看不清?
用户名:
密 码:
注册
|
忘记密码
登录
注册
返回首页
门户
|
论坛
|
Blog
|
新闻
|
文档
|
Tag
|
下载
|
搜索
|
培训
|
WiKi
|
IXPUB
|
投稿
|
专题
频道:
Oracle
|
DB2
|
SQL Server
|
ERP
|
SCM
|
Java
|
微软技术
|
开源
|
项目管理
|
SOA
|
商业智能
|
IBM软件技术
您的位置:
首页
>
技术频道
> 正文
初用ruby的几个注意事项
[
收藏此页
] [
打印
]
作者:
佚名
2007-09-05
内容导航:
初用ruby的几个注意事项
第1页:
初用ruby的几个注意事项
【IT168 技术文档】
今天按照Agile Web Development with Rails 的depot例子,准备根据数据库表自动生成scaffold,
那天在公司把这个例子做了一遍,觉得挺顺利,没想到今天换到家里的机子后,出现了不少问题.
在这里记录一下出现的问题及解决办法.
1.创建好数据库和products表后,执行
cmd>ruby script/generate scaffold product
结果报错
exists app
/
controllers
/
error Before updating scaffolding from
new
DB schema,
try
creating a ta
le
for
your model (Product)
在google上搜了一下,大概有2种解决办法:
(1) 在database.yml文件中,在密码项前面加个空格(原文地址
http://www.javaeye.com/post/264530
)
(2) 数据表名称没有复数,默认情况下,如果表为products,则命令相应为....scaffold product
这个规则可以在相应的配置文件中修改,具体可以google,这里不多讲了.
这两种方法都试过了,但问题依旧.
(3)无意中打开database.yml文件,发现有这样几句提示:
# Install the MySQL driver:
# gem install mysql
# On MacOS X:
# gem install mysql
--
--
include
=/
usr
/
local
/
lib
# On Windows:
# gem install mysql
# Choose the win32 build.
# Install MySQL and put its
/
bin directory on your path.
于是执行了gem install mysql,之后问题就解决了.奇怪的是我在办公室一样的环境,没有执行gem install mysql,也没有出现过该问题.唯一的区别,呵呵,大概就是家里网速慢,那天gem intall rails时
中断了好几次,不过这个问题总算解决了..
2. 连接数据库编码问题
生成scaffold后,就可以CRUD了,但是发现执行完CRUD后,mysql数据库中记录为乱码,执行
mysql>set names gbk后,还是显示乱码,depot数据库、products表均已设置为utf8格式,在
database.yml中加入
encoding:utf8
后,问题解决.
development:
adapter: mysql
database: depot
username: root
password:
host: localhost
encoding: utf8
1
1
【内容导航】
第1页:
初用ruby的几个注意事项
©版权所有。未经许可,不得转载。
[责任编辑:
李宁
]
[an error occurred while processing this directive]
[an error occurred while processing this directive]
[an error occurred while processing this directive]
CopyRight 1999-2006 itpub.net All Right Reserved. E-mail:Webmaster@itpub.net
北京皓辰广域网络信息技术有限公司. 版权所有
京ICP证:010037号
联系我们
法律顾问