parent
c7beefa556
commit
0c22d409fc
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,21 @@
|
||||
class ProjectStatus < ActiveRecord::Base
|
||||
attr_accessible :changesets_count, :watchers_count, :project_id
|
||||
belongs_to :projects
|
||||
belongs_to :watchers
|
||||
belongs_to :changesets
|
||||
validates_presence_of :project_id
|
||||
validates_uniqueness_of :project_id
|
||||
|
||||
|
||||
# 更新字段 watchers_count 加1 这里没有做用户是否存在的匹配
|
||||
# 负责这个表的聂同学 是在新建用户时就新建了该表的记录
|
||||
# 但是 如果超级用户删除其他用户的话会造成读取错误 这里是遗漏点
|
||||
# 删除用户时 此表创建人员未作相应删除动作
|
||||
def update_watchers_count(num)
|
||||
if self.watchers_count >= 0
|
||||
self.update_attribute(:watchers_count, self.watchers_count.to_i + num)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
@ -1,11 +0,0 @@
|
||||
class UserExtension < ActiveRecord::Base
|
||||
attr_accessible :birthday, :brief_introduction, :fans_num, :finish_project_num, :follow_num, :gender, :good_num, :location, :occupation, :publish_requirement_num, :user_id, :work_experience, :zip_code
|
||||
|
||||
belongs_to :user
|
||||
validate :validate_user
|
||||
|
||||
def validate_user
|
||||
errors.add :user_id, :invalid if user.nil? || !user.active? || User.current != user_id
|
||||
end
|
||||
|
||||
end
|
@ -0,0 +1,20 @@
|
||||
class UserStatus < ActiveRecord::Base
|
||||
attr_accessible :changesets_count, :user_id, :watchers_count
|
||||
belongs_to :users
|
||||
belongs_to :watchers
|
||||
belongs_to :changesets
|
||||
validates_presence_of :user_id
|
||||
validates_uniqueness_of :user_id
|
||||
|
||||
|
||||
# 更新字段 watchers_count 加1 这里没有做用户是否存在的匹配
|
||||
# 负责这个表的聂同学 是在新建用户时就新建了该表的记录
|
||||
# 但是 如果超级用户删除其他用户的话会造成读取错误 这里是遗漏点
|
||||
# 删除用户时 此表创建人员未作相应删除动作
|
||||
def update_watchers_count(num)
|
||||
if self.watchers_count >= 0
|
||||
self.update_attribute(:watchers_count, self.watchers_count.to_i + num)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in new issue