Class: Image

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/image.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) as_json(options = {})



18
19
20
21
22
23
24
25
26
27
28
# File 'app/models/image.rb', line 18

def as_json(options = {})
  options.merge!(only: [:id, :file_name, :created_at])

  json = super(options)
  json['url'] = if options[:resolution]
                  file.thumb(options[:resolution]).url
                else
                  file.url
                end
  json
end

- (Object) resolution



14
15
16
# File 'app/models/image.rb', line 14

def resolution
  [file.width, file.height]
end

- (Object) url



10
11
12
# File 'app/models/image.rb', line 10

def url
  file.url
end