scinote-web/app/models/repository_list_value.rb

24 lines
629 B
Ruby
Raw Normal View History

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
belongs_to :created_by,
foreign_key: :created_by_id,
2018-02-09 21:11:56 +08:00
class_name: 'User'
belongs_to :last_modified_by,
foreign_key: :last_modified_by_id,
2018-02-09 21:11:56 +08:00
class_name: 'User'
has_one :repository_cell, as: :value, dependent: :destroy, inverse_of: :value
accepts_nested_attributes_for :repository_cell
validates :repository_cell, presence: true
def formatted
data.to_s
end
def data
return nil unless repository_list_item
2018-02-09 23:28:21 +08:00
repository_list_item.data
end
end