1
我正在構建Rails 3應用程序,我需要一些幫助爲我的數據庫設計。我有模型叫做Post
。 Posts
也包含Tutorial
,Example
和Comments
。Rails 3數據庫設計爲郵政模型
評論有自己的模型,但我想知道我應該建立自己的模型Tutorials
和Examples
?
教程和示例包含大量鏈接。現在我應該如何構建它?
Post
has_one :tutorial
has_one :example
Tutorial
belongs_to :post
Example
belongs_to :post
或者我應該只是把教程和實例字段Posts
表?教程和示例僅在用戶查看發佈時顯示。
''Tutorial'and僅Example'has一個屬性。只有關聯是'belongs_to:post'。 – Oneil
@Oneil在這種情況下(如果您確信它稍後不會變得更復雜),只需在「Post」模型中添加教程和示例字段 – DanS
它們只是文本嗎? – DanS