【发布时间】:2019-05-10 15:59:36
【问题描述】:
我对 Carriwave/Cloudinary 有疑问。
由于管理空间,我为一篇文章添加了一张图片。问题是当我上传它时出现以下错误。
我在 Windows 上,我使用命令行 Ubuntu for Windows。可以从那里来吗?
这是我的代码:
post.rb 在管理员中:
ActiveAdmin.register Post do
permit_params :title, :content, :photo
index do
selectable_column
id_column
column "titre", :title
column "Contenu", :content
column "Création", :created_at
column "Editer", :updated_at
actions
end
form do |f|
f.inputs do
f.input :title, required: true, hint: 'Merci d\'ajouter un titre'
f.input :content, :class => "tinymce", :rows => 40, :cols => 120, required: true
f.input :photo, required: true, hint: 'Photo obligatoire'
actions
end
end
end
photo_uploader.rb
class PhotoUploader < CarrierWave::Uploader::Base
include Cloudinary::CarrierWave
version :large do
process resize_to_fill: [350,200]
end
version :standard do
process resize_to_fill: [250,200, :north]
end
version :thumb do
process resize_to_fit: [50,50]
end
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
process resize_to_fit: [200, 200]
def extension_whitelist
%w(jpg jpeg gif png)
end
end
post.rb
has_many :comments
mount_uploader :photo, PhotoUploader
【问题讨论】:
-
我在使用
rest-client版本2.0.0时遇到了同样的问题。升级到2.1.0解决了这个问题。查看错误堆栈跟踪,似乎它可能是同一个问题,因此请查看您是否可以更新carrierwave gem 或手动将rest-client版本指定为>= 2.0.1。
标签: ruby-on-rails carrierwave cloudinary