如果我尝试在视图中尝试以下方法之一,那么它将起作用:
<%= image_tag upload.variant(resize_to_limit: [75, 75]) %>
<%= image_tag upload.variant(resize_to_fill: [300, 200]) %>
但是当我从模型实现为具有更多配置的文档时,例如:
models / todo.rb
require "image_processing/mini_magick"
class Todo < ApplicationRecord
has_many_attached :uploads
def thumb_magick image
pipeline = ImageProcessing::MiniMagick.source(image)
result = pipeline.resize_to_fill(400, 400)
end
end
视图/todos/show.html.erb
<%= image_tag(@todo.thumb_magick(upload)) %>
然后在视图中弹出此错误消息:
application.rb
config.active_storage.variant_processor
配置:
宝石文件
Github: