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

25 lines
707 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
6 years ago
def identifier
value = nil
6 years ago
value = container.try(:identifier) rescue nil
if value.blank? && parent_container_type
value = parent_container_type.try(:identifier) rescue nil
end
6 years ago
if value.blank? && belong_container_type
value = belong_container.try(:identifier) rescue nil
6 years ago
end
6 years ago
value
end
6 years ago
end