I'm building a wiki system for an application. The essence of the design is that there is an Article model, and each Article has_many Revisions. When it's time to display an Article, the most recent Revision is pulled up to get all relevant information.
This seems like a perfect case to use an accepts_nested_attributes_for so that editing the Article would accept the changes on behalf of the Revisions. However, I can't seem to figure out a way to keep all old Revisions, and have changes be made by creating a new Revision on every edit. Is there any way to make this work?
For those who prefer things less abstract:
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