From da5db36b4cb29cd2a0f6ef6d4b0b04bc3841e8b9 Mon Sep 17 00:00:00 2001 From: BenClaw Date: Mon, 8 Jun 2026 21:46:44 +0200 Subject: [PATCH] =?UTF-8?q?Migrate=20Paperclip=20=E2=86=92=20has=5Flocal?= =?UTF-8?q?=5Fattached=20in=20Image,=20News,=20Quote=20models?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 1 - app/models/cmtool/image.rb | 19 +++++-------------- app/models/cmtool/news.rb | 14 +++----------- app/models/cmtool/quote.rb | 14 +++----------- cmtool.gemspec | 1 - 5 files changed, 11 insertions(+), 38 deletions(-) diff --git a/Gemfile b/Gemfile index 77ec491..78d14f1 100644 --- a/Gemfile +++ b/Gemfile @@ -26,7 +26,6 @@ gem 'simply_couch' , github: 'bterkuile/simply_couch', branch: 'master' gem 'devise' gem 'devise_simply_couch', github: 'bterkuile/devise_simply_couch', branch: 'master' gem 'slim-rails' -gem 'paperclip', ['>= 3.4', '!= 4.3.0'] gem 'email_validator' # Declare any dependencies that are still in development here instead of in # your gemspec. These might include edge Rails or gems from your path or diff --git a/app/models/cmtool/image.rb b/app/models/cmtool/image.rb index b60db48..c075c89 100644 --- a/app/models/cmtool/image.rb +++ b/app/models/cmtool/image.rb @@ -1,20 +1,11 @@ module Cmtool class Image include SimplyCouch::Model - include Paperclip::Glue - # TODO: Replace Paperclip with SimplyCouch::HasAttachment - # 1. Change `include Paperclip::Glue` to `include SimplyCouch::HasAttachment` - # 2. Replace `has_attached_file :file, styles: {...}` with `has_attachment :file, styles: {...}` - # 3. Replace `validates_attachment` with standard Rails validations - - property :file_file_name - property :file_content_type - property :file_file_size, type: Integer - property :file_updated_at, type: Time - has_attached_file :file, styles: { page: '728x10000>', medium: "354x1000>", thumb: "160x1250>" }, - path: ":rails_root/public/system/:attachment/:id/:style.:extension", - url: "/system/:attachment/:id/:style.:extension" - validates_attachment :file, presence: true, content_type: { content_type: ["image/jpeg", "image/gif", "image/png"] } + # Paperclip → has_local_attached migration + has_local_attached :file, + styles: { page: '728x10000>', medium: '354x1000>', thumb: '160x1250>' }, + content_type: %w[image/jpeg image/gif image/png] + validates :file_file_name, presence: true belongs_to :directory diff --git a/app/models/cmtool/news.rb b/app/models/cmtool/news.rb index c1133e1..e5f9718 100644 --- a/app/models/cmtool/news.rb +++ b/app/models/cmtool/news.rb @@ -1,22 +1,14 @@ module Cmtool class News include SimplyCouch::Model - include Paperclip::Glue - # TODO: Replace Paperclip with SimplyCouch::HasAttachment - # 1. Change `include Paperclip::Glue` to `include SimplyCouch::HasAttachment` - # 2. Replace `has_attached_file :image, styles: {...}` with `has_attachment :image, styles: {...}` - property :title property :active, type: :boolean, default: true property :date, type: Date property :body - property :image_file_name - property :image_content_type - property :image_file_size, type: Integer - property :image_updated_at, type: Time - - has_attached_file :image, styles: { :medium => "500x500>", :thumb => "250x250>" } + # Paperclip → has_local_attached migration + has_local_attached :image, + styles: { medium: '500x500>', thumb: '250x250>' } has_and_belongs_to_many :keywords, storing_keys: true validates :title, presence: true validates :date, presence: true diff --git a/app/models/cmtool/quote.rb b/app/models/cmtool/quote.rb index 5db2c08..1c9946b 100644 --- a/app/models/cmtool/quote.rb +++ b/app/models/cmtool/quote.rb @@ -1,11 +1,6 @@ module Cmtool class Quote include SimplyCouch::Model - include Paperclip::Glue - # TODO: Replace Paperclip with SimplyCouch::HasAttachment - # 1. Change `include Paperclip::Glue` to `include SimplyCouch::HasAttachment` - # 2. Replace `has_attached_file :image, styles: {...}` with `has_attachment :image, styles: {...}` - property :owner property :function property :state @@ -13,12 +8,9 @@ module Cmtool property :active, type: :boolean, default: true property :locale - property :image_file_name - property :image_content_type - property :image_file_size, type: Integer - property :image_updated_at, type: Time - - has_attached_file :image, styles: {medium: "300x1000>", thumb: "137x1250>" } + # Paperclip → has_local_attached migration + has_local_attached :image, + styles: { medium: '300x1000>', thumb: '137x1250>' } view :for_sidebar_view, key: [:state, :created_at], conditions: %{doc['active']} STATES = %w[page sidebar] diff --git a/cmtool.gemspec b/cmtool.gemspec index b106fbe..67d8a1f 100644 --- a/cmtool.gemspec +++ b/cmtool.gemspec @@ -23,7 +23,6 @@ Gem::Specification.new do |s| s.add_runtime_dependency "slim-rails", ">= 0" # s.add_runtime_dependency "tinymce-rails", ">= 0" s.add_runtime_dependency "jquery-rails", ">= 0" - s.add_runtime_dependency "paperclip", ">= 0" s.add_runtime_dependency "foundation-rails", ">= 0" s.add_runtime_dependency "ace-rails-ap", ">= 0" s.add_runtime_dependency "font-awesome-rails", ">= 0"