You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/models/tiding.rb

26 lines
825 B

6 years ago
class Tiding < ApplicationRecord
belongs_to :user
belongs_to :trigger_user, class_name: 'User', optional: true
belongs_to :container, polymorphic: true, optional: true
belongs_to :parent_container, polymorphic: true, optional: true
belongs_to :belong_container, polymorphic: true, optional: true
has_many :attachments, as: :container
5 years ago
def identifier
value = nil
if Object.const_defined?(container_type)
value = container.try(:identifier)
end
if value.blank? && parent_container_type && Object.const_defined?(parent_container_type)
value = parent_container_type.try(:identifier)
end
5 years ago
if value.blank? && belong_container_type && Object.const_defined?(belong_container_type)
value = belong_container.try(:identifier)
end
5 years ago
value
end
6 years ago
end