metamaps--metamaps/app/models/attachment.rb
Devin Howard 4a99d74fd8 rubocop
2017-01-22 16:28:18 -05:00

26 lines
681 B
Ruby

# frozen_string_literal: true
class Attachment < ApplicationRecord
belongs_to :attachable, polymorphic: true
has_attached_file :file,
styles: lambda { |a|
if a.instance.image?
{
small: 'x200>',
medium: 'x300>',
large: 'x400>'
}
else
{}
end
}
validates_attachment_content_type :file, content_type: [
%r{\Aimage/.*\Z},
%r{\Avideo/.*\Z}
]
def image?
file.instance.file_content_type =~ /image/
end
end