educoder/app/models/project.rb

21 lines
386 B

class Project < ApplicationRecord
belongs_to :owner, class_name: 'User', foreign_key: :user_id
has_many :members
has_one :project_score, dependent: :destroy
has_many :issues
# 创建者
def creator
User.find(user_id).full_name
end
def project_members
self.members
end
def member?(user)
members.exists?(user_id: user.id)
end
end