2010-10-19 83 views
0

嘿,我試圖用Mongoid(對於MongoDB)構建一個rails 3應用程序。 什麼我現在要做的:用Mongoid爲這個數據庫結構定義模型


語言:

ID(自動創建的,對吧?)

名稱(如英語)

代碼(例如en_US)

Lan guages_Texts:

ID(見上文...)

名稱(例如程序hello_world)

翻譯:

ID(見上文......)

翻譯(如你好,世界)


我希望這個數據庫模式是可以理解的!並不是太糟糕。 ;)

現在我的問題是,我不知道如何在一個鐵軌模型mongoid 3.

任何人都可以幫助我做到這一點?

已經謝謝了!

馬蒂亞斯

回答

1

看起來像所有你需要的是三種不同的模式,語言,languages_text和翻譯。這些模型應該看起來像這樣

class Language 
    include Mongoid::Document 
    field :name 
    field :code 
end 

class LanguagesText 
    include Mongoid::Document 
    field :name 
end 

class Translation 
    include Mongoid::Document 
    field :translation 
end 

這會將數據放入mongodb中的不同集合中。希望有幫助