You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
803 B
22 lines
803 B
class ProjectStatus < ActiveRecord::Base
|
|
attr_accessible :changesets_count, :watchers_count, :project_id, :project_type,:grade
|
|
belongs_to :project
|
|
belongs_to :watchers
|
|
belongs_to :changesets
|
|
validates_presence_of :project_id
|
|
validates_uniqueness_of :project_id
|
|
|
|
scope :visible, lambda {|*args| nil }
|
|
# 更新字段 watchers_count 加1 这里没有做用户是否存在的匹配
|
|
# 负责这个表的聂同学 是在新建用户时就新建了该表的记录
|
|
# 但是 如果超级用户删除其他用户的话会造成读取错误 这里是遗漏点
|
|
# 删除用户时 此表创建人员未作相应删除动作
|
|
def update_watchers_count(num)
|
|
if self.watchers_count||0 >= 0
|
|
self.update_attribute(:watchers_count, self.watchers_count.to_i + num)
|
|
end
|
|
end
|
|
|
|
|
|
end
|