2016-07-21 16:09:07 +08:00
|
|
|
class Commit < ActiveRecord::Base
|
|
|
|
attr_accessible :comments, :committed_on, :committer, :project_id, :repository_id, :version
|
2016-07-22 10:34:59 +08:00
|
|
|
validates :repository_id, presence: true
|
|
|
|
validates :version, presence: true, uniqueness: {scope: :repository_id}
|
|
|
|
validates :committed_on, presence: true
|
2016-07-21 16:09:07 +08:00
|
|
|
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
|
|
|
|
after_create :act_as_forge_activity
|
|
|
|
|
|
|
|
# 项目中提交动态
|
|
|
|
def act_as_forge_activity
|
|
|
|
self.forge_acts << ForgeActivity.new(:user_id => 2, :project_id => self.project_id)
|
|
|
|
end
|
|
|
|
end
|