1. ruby和数据库的连接
ruby的贡献者实现了很多连接外围数据库的interface,大都基于C。即在DHH之前,这些库已经存在。连接到oracle、通过ruby的接口有许多,目前OCI8占优。它们实现了类似jdbc的功能。
2. ActiveRecord
Rails and Active Record are both projects conceived by DavidHeinemeierHansson and improved upon by a number of Contributors.(http://wiki.rubyonrails.org/rails/pages/ActiveRecord )
ActiveRecord是ruby中一个独立的ORM lib,DHH也将其作为rails中的model 部分。
pattern. In essence, it ties database tables to classes so that the data can be manipulated
intuitively without SQL. To be more specific, it "wraps a row in a database table or view,
encapsulates the database access, and adds domain logic on that data"
The ubiquity of both these models (RDBMS and OOP) and the "impedance mismatch" between
them has led many people to try to bridge this gap. The software bridge that accomplishes
this is called an Object-Relational Mapper (ORM).
3. fastCGI和lighttpd
Apache实现fcgi的插件有问题,所以不能使用来搭配rails(知道不能是fcgi的方式)。
lighttpd的配置备忘。
要用Apache只能低于1.3版本,因为apache的fcgi对应插件在04年就停止开发,1.3之后的版本都有兼容性问题。
server.error-handler-404 = "/dispatch.fcgi"
这句话使得可以把动态资源定向到ruby的fcgi进程。
############ BEGIN HIGHLIGHT ################## fastcgi.server = ( ".fcgi" => ( "localhost-8000" => ( "host" => "127.0.0.1", "port" => 8000 ) , "localhost-8001" => ( "host" => "127.0.0.1", "port" => 8001 ) , "localhost-8002" => ( "host" => "127.0.0.1", "port" => 8002 ) ) ) ############ END HIGHLIGHT ##################
cgi是每次启动一个进程来执行脚本,执行完毕返回结果后消除进程。fcgi是把请求分发给某个事先跑起来的进程,执行完毕后进程进入后续队列。
疑问是cgi这种运行方式怎么会产生的,而且还存在了那么多年。