Sha256: 3e8708f9a3a63cd92c2897144c6e02886b78c069c1c41d19e99c21fc95184d6b
Contents?: true
Size: 967 Bytes
Versions: 1
Compression:
Stored size: 967 Bytes
Contents
module ChooChoo # A new activity is created when a ParentNode is created # the event_happened method is called whenever there is a state change for the # tracked models using Activity as a ParentNode or a ChildNode class Activity < ActiveRecord::Base attr_accessible :last_action, :parent_node, :last_updated_node belongs_to :parent_node, polymorphic: true belongs_to :last_updated_node, polymorphic: true after_create :on_create # Initial creation of a new activity with a ParentNode set to the model # in the hosting app using choo_choo that will act as a parent def on_create self.event_happened('created', self.parent_node) end # Tracks model changes (created, updated, deleted) # Wether it's a parent or child node def event_happened(event_name, model) self.last_action = event_name self.last_updated_node = model self.updated_at = Time.zone.now self.save! end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
choo_choo-0.0.1 | app/models/choo_choo/activity.rb |