class Attachment
Public Instance Methods
to_s()
click to toggle source
# File lib/buweb/attachment.rb, line 37 def to_s self.name.presence || (attachment.present? && ::File.basename(attachment.path)) || "Attachment is uninitialized" end
Private Instance Methods
ensure_attachable_id_is_bson_object_id()
click to toggle source
This was causing some weird issues with attachments being polymorphic. Even though the attachment had the class and id correct, it wouldn't show up under @academic_program.attachments. Keeping it for now until someone can take a closer look.
# File lib/buweb/attachment.rb, line 50 def ensure_attachable_id_is_bson_object_id if attachable_id.is_a? String self.attachable_id = BSON::ObjectId.from_string attachable_id end end
set_order()
click to toggle source
# File lib/buweb/attachment.rb, line 43 def set_order self.order ||= Attachment.where(attachable_id: attachable_id).count + 1 end