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]
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]