Files
nairobi/app/models/concerns/imageable.rb
2017-12-12 12:38:54 +01:00

13 lines
316 B
Ruby

module Imageable
extend ActiveSupport::Concern
included do
has_one :image, as: :imageable, dependent: :destroy
accepts_nested_attributes_for :image, allow_destroy: true, update_only: true
def image_url(style)
image.attachment.url(style) if image && image.attachment.exists?
end
end
end