Class: RestaurantPictureUploader

Inherits:
ApplicationUploader show all
Defined in:
app/uploaders/restaurant_picture_uploader.rb

Overview

typed: ignore encoding: utf-8 frozen_string_literal: true

Instance Method Summary collapse

Methods inherited from ApplicationUploader

#extension_whitelist, #quality, #validate_dimensions

Instance Method Details

#cover_tag?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'app/uploaders/restaurant_picture_uploader.rb', line 28

def cover_tag?(*)
  model.has_cover_tag?
end

#default_urlObject



12
13
14
# File 'app/uploaders/restaurant_picture_uploader.rb', line 12

def default_url
  '/img/hh_logo.png'
end

#store_dimensionsObject



16
17
18
19
20
21
22
23
24
25
26
# File 'app/uploaders/restaurant_picture_uploader.rb', line 16

def store_dimensions
  return unless file && model && file.exists?
  begin
    img = MiniMagick::Image.open(file.file)
    model.width = img.width
    model.height = img.height
  rescue => e
    HH_LOGGER.info('unable to read image width and height', { path: file.file, model: model, exception: e })
    true
  end
end

#store_dirObject



8
9
10
# File 'app/uploaders/restaurant_picture_uploader.rb', line 8

def store_dir
  "uploads/restaurants/#{model.restaurant_id}/photos/#{model.id}"
end