36 lines
965 B
Ruby
36 lines
965 B
Ruby
# == Schema Information
|
|
#
|
|
# Table name: user_clas
|
|
#
|
|
# id :integer not null, primary key
|
|
# user_id :integer not null
|
|
# cla_id :integer not null
|
|
# real_name :string(255) not null
|
|
# email :string(255) not null
|
|
# state :integer default("0")
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
#
|
|
# Indexes
|
|
#
|
|
# index_user_clas_on_cla_id (cla_id)
|
|
# index_user_clas_on_user_id (user_id)
|
|
#
|
|
|
|
class UserCla < ApplicationRecord
|
|
belongs_to :user
|
|
belongs_to :cla
|
|
# identity 0: 教师教授 1: 学生, 2: 专业人士, 3: 开发者
|
|
enum state: { deafult: 0, signed: 1, failed: 2}
|
|
|
|
def self.build(params,user_id)
|
|
self.create!(user_id: user_id,
|
|
cla_id: params[:cla_id],
|
|
real_name: params[:real_name],
|
|
email: params[:email],
|
|
state: 1
|
|
)
|
|
end
|
|
|
|
end
|