2018-02-07 22:28:28 +08:00
|
|
|
class RepositoryListValue < ApplicationRecord
|
2018-02-09 23:28:21 +08:00
|
|
|
belongs_to :repository_list_item,
|
2018-02-09 21:11:56 +08:00
|
|
|
optional: true
|
2018-02-07 22:28:28 +08:00
|
|
|
belongs_to :created_by,
|
|
|
|
foreign_key: :created_by_id,
|
2018-02-09 21:11:56 +08:00
|
|
|
class_name: 'User'
|
2018-02-07 22:28:28 +08:00
|
|
|
belongs_to :last_modified_by,
|
|
|
|
foreign_key: :last_modified_by_id,
|
2018-02-09 21:11:56 +08:00
|
|
|
class_name: 'User'
|
2018-02-07 22:28:28 +08:00
|
|
|
has_one :repository_cell, as: :value, dependent: :destroy, inverse_of: :value
|
|
|
|
accepts_nested_attributes_for :repository_cell
|
|
|
|
|
|
|
|
validates :repository_cell, presence: true
|
|
|
|
|
2018-02-09 18:38:52 +08:00
|
|
|
def formatted
|
2018-03-05 22:54:04 +08:00
|
|
|
data.to_s
|
|
|
|
end
|
|
|
|
|
|
|
|
def data
|
|
|
|
return nil unless repository_list_item
|
2018-02-09 23:28:21 +08:00
|
|
|
repository_list_item.data
|
2018-02-07 22:28:28 +08:00
|
|
|
end
|
|
|
|
end
|