Skip to content

Instantly share code, notes, and snippets.

@ahawkins
Created January 5, 2011 10:31
Show Gist options
  • Save ahawkins/766144 to your computer and use it in GitHub Desktop.
Save ahawkins/766144 to your computer and use it in GitHub Desktop.
module RadiumCRM
module ActsAsActivity
def self.included(base)
base.class_eval do
has_many :activities, :as => :reference, :dependent => :destroy do
def create_with_tags(*tags)
activity = build :account => @owner.account
activity.tag_list.add @owner.class.to_s.underscore
activity.tag_list.add(tags)
activity.tag_list.add(@owner.state) if @owner.respond_to?(:state)
activity.tag_list.add @owner.associated_tags
activity.save!
activity
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment