第一个rails程序

color=green][/color]刚才用rails框架做了一个简单的例子,这里我把遇天的问题写一下,希望以后遇到同样的问题能想起解决办法... :P
1,建一个ruby工作空间(习惯了这么叫)>md rubydev
>cd rubydev
>rails frist
>ruby script/server
2,打开firefox 输入http://127.0.0.1:3000
看到页面能正确显示

3,创建一个控制器,编辑hello_controller.rb文件:
class HelloController < ApplicationController
def there
end
end

4,创建视图:hello.rhml
<html>
<head><title>hello</title></head>
<body>
<marquee>hello,ruby</marquee>
</body>
</html>

5启动服务器:> ruby script/server
6,打开firefox 输入http://127.0.0.1:3000/hello/there

这个时候页面出错了,
MissingSourceFile in SayController#
no such file to load -- sqlite3
(2)修改database.yml文件:
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql
# On Mac OS X:
# sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
# On Mac OS X Leopard:
# sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
# This sets the ARCHFLAGS environment variable to your native architecture
# On Windows:
# gem install mysql
# Choose the win32 build.
# Install MySQL and put its /bin directory on your path.
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql
encoding: utf8
database: demo
pool: 5
username: root
password: linlin
host: localhost
socket: /opt/local/var/run/mysql5/mysqld.sock


# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: mysql
encoding: utf8
database: second_test
pool: 5
username: root
password: linlin
host: localhost
socket: /opt/local/var/run/mysql5/mysqld.sock


production:
adapter: mysql
encoding: utf8
database: demo
pool: 5
username: root
password: linlin
host: localhost
socket: /opt/local/var/run/mysql5/mysqld.sock

这里我用的是第二种方法,没办法,用了很久的mysql了,呵呵

7,重启:>ruby script/server

在此,期待的页面出现,搞定!!!

不写了,还得去做编译原理,计算机网络,背单词(咱六级还没过啊....),哎,ruby.....

[url=http://bbs.langsin.com/LangsinBbsRegister.php?fromuid=53534]浪曦视频在线![/url]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值