FLOChip/mongoid_timeline_fu — pull request #1 by nfedyashev (2012-05-19 02:21:57+00:00)
Title: let TimelineEvent save additional fields

Hi there!

In my project I have this task - `TimelineEvent` must have some additional info that come along with certain events. Unfortunately references to actor, subject, secondary subject and and event_type itself is not always enough.

so this is simplified version of what I have in my project:

class Annotation
include Mongoid::Document

fires :new_annotation, :on => :create,
:memo => :fetch_memo_value,
:actor => :project
def fetch_memo_value
# fetch some value based on a certain algorithm
end
end

class TimelineEvent
include Mongoid::Document
include Mongoid::Timestamps::Created

field :memo, :type => String
field :event_type, :type => String

belongs_to :actor, :polymorphic => true
belongs_to :subject, :polymorphic => true
belongs_to :secondary_subject, :polymorphic => true
end

If you're OK with this commit I'll add necessary updates to the README in this pull-request. So this is more like a start of conversation than a finished pull request.

Meanwhile I'm using my fork with this commit in production and it works as expected.