Building a wiki like data model in rails question.
- by lillq
I have a data model in which I would like to have an item that has a description that can be edited. I would like to also keep track of all edits to the item. I am running into issues with my current strategy, which is:
class Item < ActiveRecord::Base
has_one :current_edit,
:class_name => "Edit",
:foreign_key => "current_edit_id"
has_many :edits
end
class Edit < ActiveRecord::Base
belongs_to :item
end
Can the Item have multiple associations to the same class like this?
I was thinking that I should switch to keeping track of the edit version in the Edit object and then just sorting the has_many relationship base on this version.