about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAkihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>2017-09-03 14:58:58 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-09-03 07:58:58 +0200
commit249bdc169cd52ad9adc7bda1c47c74c22bb01369 (patch)
tree689ff08d5e2f0613ee0c49b962bb87f5330bbed9
parent9dd8dff683a148bdd00d715e85b7af40c3d4be21 (diff)
Explicitly define attached file of DeprecatedPreviewCard (#4786)
The path template of the attached files must explicitly be defined because
it is contradicting to the name of the class.
-rw-r--r--lib/tasks/mastodon.rake11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake
index f04201a3c..f4f6e4d23 100644
--- a/lib/tasks/mastodon.rake
+++ b/lib/tasks/mastodon.rake
@@ -275,8 +275,15 @@ namespace :mastodon do
     task remove_deprecated_preview_cards: :environment do
       return unless ActiveRecord::Base.connection.table_exists? 'deprecated_preview_cards'
 
-      class DeprecatedPreviewCard < PreviewCard
-        self.table_name = 'deprecated_preview_cards'
+      class DeprecatedPreviewCard < ActiveRecord::Base
+        self.inheritance_column = false
+
+        path = '/preview_cards/:attachment/:id_partition/:style/:filename'
+        if ENV['S3_ENABLED'] != 'true'
+          path = (ENV['PAPERCLIP_ROOT_PATH'] || ':rails_root/public/system') + path
+        end
+
+        has_attached_file :image, styles: { original: '280x120>' }, convert_options: { all: '-quality 80 -strip' }, path: path
       end
 
       puts 'Delete records and associated files from deprecated preview cards? [y/N]: '