Class: Activity

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/activity.rb

Overview

Schema Information

Table name: activities

id            :integer(4)      not null, primary key
item_id       :integer(4)
item_type     :string(255)
template      :string(255)
source_id     :integer(4)
source_type   :string(255)
content       :text
title         :string(255)
status_update :boolean(1)
created_at    :datetime
updated_at    :datetime

Instance Method Summary collapse

Instance Method Details

#can_edit?(check_object) ⇒ Boolean

Checks to see if the specified object can edit this activity. Most likely check_object will be a user

Returns:

  • (Boolean)


53
54
55
56
57
58
59
60
# File 'app/models/activity.rb', line 53

def can_edit?(check_object)
  if check_object.is_a?(User)
    return true if check(check_object, :source_id)
  else
    source == check_object
  end
  false
end

#has_comments?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'app/models/activity.rb', line 47

def has_comments?
  @has_comments ||= !self.comments.blank?
end

#partialObject

Provides a template that can be used to render a view of this activity. If ‘template’ is not specified when the object created then the item class name will be used to generated a template



43
44
45
# File 'app/models/activity.rb', line 43

def partial
  template || item.class.name.underscore
end

#validateObject



36
37
38
# File 'app/models/activity.rb', line 36

def validate
  errors.add_to_base(I18n.t('muck.activities.template_or_item_required')) if template.blank? && item.blank?
end