diff --git a/app/decorators/practice_decorator.rb b/app/decorators/practice_decorator.rb deleted file mode 100644 index 2e42f9b3746..00000000000 --- a/app/decorators/practice_decorator.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -module PracticeDecorator - OGP_IMAGE_SIZE = [1200, 630].freeze - - def ogp_image_url - default_image_path = '/ogp/ogp.png' - - if ogp_image.attached? - ogp_image.variant(resize_to_fill: OGP_IMAGE_SIZE, autorot: true, saver: { strip: true, quality: 60 }).processed.url - else - image_url default_image_path - end - rescue ActiveStorage::FileNotFoundError, ActiveStorage::InvariableError, Vips::Error - image_url default_image_path - end -end diff --git a/app/models/practice.rb b/app/models/practice.rb index 3103daa6be0..348288039cc 100644 --- a/app/models/practice.rb +++ b/app/models/practice.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class Practice < ApplicationRecord + OGP_IMAGE_SIZE = [1200, 630].freeze + include Watchable include Searchable @@ -168,6 +170,18 @@ def include_must_read_books? practices_books.any?(&:must_read) end + def ogp_image_url + default_image_path = '/ogp/ogp.png' + + if ogp_image.attached? + ogp_image.variant(resize_to_fill: OGP_IMAGE_SIZE, autorot: true, saver: { strip: true, quality: 60 }).processed.url + else + image_url default_image_path + end + rescue ActiveStorage::FileNotFoundError, ActiveStorage::InvariableError, Vips::Error + image_url default_image_path + end + private def total_learning_minute(report)