Upgrade from Rails 5.0 to 5.2

This commit is contained in:
Christoph Haas 2020-04-13 20:15:18 +02:00
parent 820ff2a30b
commit d130f68172
29 changed files with 504 additions and 301 deletions

View file

@ -3,13 +3,15 @@ class Screenshot < ApplicationRecord
belongs_to :user, inverse_of: :screenshots
# Use paperclip gem to handle image files related to screenshots
has_attached_file :image,
styles: { :large => '800x600>', :thumb => '160x120>' },
default_url: '/images/dummy/no-screenshots-available.svg',
path: ':rails_root/public/screenshots/:id_partition/:style.png',
url: '/screenshots/:id_partition/:style.png'
validates_attachment_content_type :image, :content_type => 'image/png'
validates_with AttachmentSizeValidator, :attributes => :image, :less_than => 5.megabytes
has_one_attached :image
# has_attached_file :image,
# styles: { :large => '800x600>', :thumb => '160x120>' },
# default_url: '/images/dummy/no-screenshots-available.svg',
# path: ':rails_root/public/screenshots/:id_partition/:style.png',
# url: '/screenshots/:id_partition/:style.png'
#validates_attachment_content_type :image, :content_type => 'image/png'
#validates_with AttachmentSizeValidator, :attributes => :image, :less_than => 5.megabytes
# validate :validate_image_is_unique
validates :delete_reason, length: { in: 5..100 }, allow_nil: true
@ -59,9 +61,9 @@ class Screenshot < ApplicationRecord
end
# Return Debshots 1.x path to allow migration of images into Paperclip filesystem schema
def image_url(size)
"live/screenshots/approved/#{self.package.name[0]}/#{self.package.name}/#{self.id}_#{size}.png"
end
# def image_url(size)
# "live/screenshots/approved/#{self.package.name[0]}/#{self.package.name}/#{self.id}_#{size}.png"
# end
# Long status text for public users
def status