アプリケーション用のwikiシステムを構築しています。デザインの本質は、Articleモデルがあり、各Articlehas_manyRevisionsがあることです。記事を表示するときは、最新のリビジョンがプルアップされ、すべての関連情報が取得されます。
これは、accepts_nested_attributes_forを使用して、記事を編集するとリビジョンに代わって変更が受け入れられるようにするのに最適なケースのようです。ただし、古いリビジョンをすべて保持する方法がわからないようで、編集のたびに新しいリビジョンを作成して変更を加えることができます。これを機能させる方法はありますか?
抽象度の低いものを好む人のために:
class Article
has_many :revisions
has_one :current_revision, :class_name => "Revision", :order => "created_at DESC"
#contains columns that are not tracked for revisions, such as the article's Url slug
end
class Revision
belongs_to :article
#contains basic columns like wiki article body
end