ruby 到 rails

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 部分。

 

 

寫道
The library for Ruby is named after Martin Fowler's "Active Record" design
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這種運行方式怎麼會產生的,而且還存在了那麼多年。



 

發佈了2 篇原創文章 · 獲贊 0 · 訪問量 923
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章