2011-03-28 38 views
0

嗨,我正在爲當地的非政府組織進行數據輸入系統,該系統對森林中的鳥類進行調查。我有四種模型,分別是Bird,Location,Report和Ratio。雖然鳥&位置只是簡單的模型只有一個名稱字段,我的報告字段如下。在紅寶石模型中計算比率

class Report < ActiveRecord::Base 

    hobo_model # Don't put anything above this 

    fields do 
    Date :date 
    Plumage enum_string(:Breeding, :NonBreeding) 
    Weather enum_string(:Cloudy, :Sunny, :Humid) 
    Time enum_string(:Dawn, :Morning, :Noon, :Evening, :Dusk, :Night) 
    timestamps 
    end 

    belongs_to :bird 
    belongs_to :location 

end 

而在比率模型中,我需要計算以下邏輯的比率。

鑑於鳥X在的位置大號發現了一個情況下,比 應等於倍鳥X的數量爲L的 數量在L.報告總報告的鳥是如何報道我從數據庫中取數據 到比率模型?

回答