Skip to content

Instantly share code, notes, and snippets.

@mickey
Created April 4, 2012 23:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mickey/2306496 to your computer and use it in GitHub Desktop.
Save mickey/2306496 to your computer and use it in GitHub Desktop.
class Activity < ActiveRecord::Base
belongs_to :user
belongs_to :target, :polymorphic => true
default_scope :order => 'activities.created_at DESC', :limit => 10
AUDITION_POSTED = 1 #target --> model audition
AUDITION_FEEDBACK_UPDATED = 2 #target --> model audition
AUDITION_VIEWED = 3 #target --> model video
NEW_PART = 4 #target --> model part
def self.add(user, activity_type, target)
return false if user.blank? or activity_type.blank? or target.blank?
activity = Activity.new(:user => user, :activity_type => activity_type, :target => target)
activity.save!
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment