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.

21 lines
490 B

  1. class MediaAttachment < ApplicationRecord
  2. belongs_to :account, inverse_of: :media_attachments
  3. belongs_to :status, inverse_of: :media_attachments
  4. has_attached_file :file
  5. validates_attachment_content_type :file, content_type: /\Aimage\/.*\z/
  6. validates :account, presence: true
  7. def local?
  8. self.remote_url.blank?
  9. end
  10. def file_remote_url=(url)
  11. unless self[:file_remote_url] == url
  12. self.file = URI.parse(url)
  13. end
  14. self[:file_remote_url] = url
  15. end
  16. end