0
如果您在#rubyonrails掛出freenode上這聽起來像一個回聲給你,因爲我以前問它在那裏2天。在花了幾個小時研究AR協會之後,在#rubyonrails討論後,我仍然感到迷失,所以我在這裏問。 :)
目標
我主持了一些博客。我的意圖是創建批量提交,在我發佈帖子的情況下,選擇我希望提交帖子的博客,然後爲該批次提交提交日期。稍後,我想創建一個查詢批次的工作人員,然後將帖子實際提交給相關的博客。
我感到困惑的困惑我應該如何設置我的協會和相應的表格。
以下是我對模型。
class Blog < ActiveRecord::Base
has_many :submissions
has_many :posts, :through => :submissions
end
class Post < ActiveRecord::Base
has_many :submissions
has_many :blogs, :through => :submissions
end
class Submission < ActiveRecord::Base
belongs_to :post
belongs_to :blog
end
這是我對桌子有什麼。
[Blogs]
id :integer not null, primary key
title :string(255)
etc
[Posts]
id :integer not null, primary key
subject :string(255)
content :text
etc
[Submissions]
id :integer not null, primary key
submit_date :datetime
post_id :integer
forum_id :integer
etc
問題
- 我目前還沒有批模型 - 我應該有這個?或者可以通過回溯提交來推斷「批次」?
- 我是否應該有一個批處理模式,將意味着那麼Submisson模型得到一個額外的外鍵?
- 有沒有更多的「軌道方式」來做到這一點?
- 歡迎任何其他意見!
非常感謝閱讀這個龐大的職位。