forked from Trustie/forgeplus
55 lines
1.5 KiB
Ruby
55 lines
1.5 KiB
Ruby
# == Schema Information
|
|
#
|
|
# Table name: competition_users
|
|
#
|
|
# id :integer not null, primary key
|
|
# competition_info_id :integer
|
|
# user_id :integer
|
|
# leader :string(255)
|
|
# org_name :string(255)
|
|
# org_job :string(255)
|
|
# org_rank :string(255)
|
|
# zone :string(255)
|
|
# sub_competition :string(255)
|
|
# subject_source_type :integer
|
|
# subject_source_name :string(255)
|
|
# phone :string(255)
|
|
# members :text(65535)
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
#
|
|
# Indexes
|
|
#
|
|
# index_competition_users_on_competition_info_id (competition_info_id)
|
|
# index_competition_users_on_user_id (user_id)
|
|
#
|
|
|
|
class CompetitionUser < ApplicationRecord
|
|
belongs_to :competition_info
|
|
belongs_to :user
|
|
|
|
has_many :attachments, as: :container, dependent: :destroy
|
|
|
|
serialize :members, JSON
|
|
|
|
# %i[real_name org_name org_job org_rank].each do |method_name|
|
|
# define_method method_name do
|
|
# members&.[](method_name.to_s)
|
|
# end
|
|
#
|
|
# define_method "#{method_name}=" do |value|
|
|
# self.config ||= {}
|
|
# members.[]=(method_name.to_s, value)
|
|
# end
|
|
# end
|
|
#
|
|
def members_to_string
|
|
return "" if members.blank?
|
|
str = []
|
|
members.each do |m|
|
|
str.push("#{m["real_name"]} #{m["org_name"]} #{m["org_job"]} #{m["org_rank"]} ")
|
|
end
|
|
str.join(";")
|
|
end
|
|
end
|