需要执行#cache!如果你想使用 Cloudinary::CarrierWave::Storage 作为缓存存储
Need to implement #cache! if you want to use Cloudinary::CarrierWave::Storage as a cache storage
我在尝试上传图片时遇到此错误 "Need to implement #cache! if you want to use Cloudinary::CarrierWave::Storage as a cache storage."
它在我的控制器中突出显示了这部分代码:
def update
@company.update(company_params)
redirect_to company_path(@company)
end
我正在使用 Carrierwave 将照片上传到 cloudinary。
我有一个包含我的配置的 cloudinary.yml 文件以及我的初始化程序中的一个 cloudinary.rb。
identitylogo_uploader.rb
class IdentitylogoUploader < CarrierWave::Uploader::Base
include Cloudinary::CarrierWave
process :convert => 'png'
process :tags => ['logo_entreprise']
version :standard do
process :resize_to_fill => [150, 150, :north]
end
version :thumbnail do
resize_to_fit(50, 50)
end
def public_id
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
company.rb
class Company < ApplicationRecord
mount_uploader :identitylogo, IdentitylogoUploader
end
companies_controller.erb
def update
@company.update(company_params)
redirect_to company_path(@company)
end
def company_params
params.require(:company).permit(:identitylogo, :name, :industry,
:employees, :website)
end
_form.erb
<%= simple_form_for @company do |f| %>
<%= f.input :name %>
<%= f.input :industry %>
<%= f.input :employees %>
<%= f.input :website %>
<%= f.input :identitylogo_cache, as: :hidden %>
<%= f.input :identitylogo, label: false %>
<%= f.button :submit %>
<% end %>
_show.html.erb
<img src="<%= @company.identitylogo %> " alt="Logo de
l'entreprise">
我注意到 link 已生成,但文件尚未上传到 cloudinary。
最新版本的 CarrierWave 似乎与 Cloudinary 不兼容。
检查你的 Gemfile 和 Gemfile.lock。我必须删除 .rc-ending 并重新启动服务器。
已将 config.cache_storage = :file
添加到载波初始化程序,错误消失了。
CarrierWave.configure do |config|
# For an application which utilizes multiple servers but does not need caches persisted across requests,
# uncomment the line :file instead of the default :storage. Otherwise, it will use the default storage as the temp cache store.
config.cache_storage = :file
end
这是更改旧行为的提交:link
我在尝试上传图片时遇到此错误 "Need to implement #cache! if you want to use Cloudinary::CarrierWave::Storage as a cache storage." 它在我的控制器中突出显示了这部分代码:
def update
@company.update(company_params)
redirect_to company_path(@company)
end
我正在使用 Carrierwave 将照片上传到 cloudinary。 我有一个包含我的配置的 cloudinary.yml 文件以及我的初始化程序中的一个 cloudinary.rb。
identitylogo_uploader.rb
class IdentitylogoUploader < CarrierWave::Uploader::Base
include Cloudinary::CarrierWave
process :convert => 'png'
process :tags => ['logo_entreprise']
version :standard do
process :resize_to_fill => [150, 150, :north]
end
version :thumbnail do
resize_to_fit(50, 50)
end
def public_id
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
company.rb
class Company < ApplicationRecord
mount_uploader :identitylogo, IdentitylogoUploader
end
companies_controller.erb
def update
@company.update(company_params)
redirect_to company_path(@company)
end
def company_params
params.require(:company).permit(:identitylogo, :name, :industry,
:employees, :website)
end
_form.erb
<%= simple_form_for @company do |f| %>
<%= f.input :name %>
<%= f.input :industry %>
<%= f.input :employees %>
<%= f.input :website %>
<%= f.input :identitylogo_cache, as: :hidden %>
<%= f.input :identitylogo, label: false %>
<%= f.button :submit %>
<% end %>
_show.html.erb
<img src="<%= @company.identitylogo %> " alt="Logo de
l'entreprise">
我注意到 link 已生成,但文件尚未上传到 cloudinary。
最新版本的 CarrierWave 似乎与 Cloudinary 不兼容。
检查你的 Gemfile 和 Gemfile.lock。我必须删除 .rc-ending 并重新启动服务器。
已将 config.cache_storage = :file
添加到载波初始化程序,错误消失了。
CarrierWave.configure do |config|
# For an application which utilizes multiple servers but does not need caches persisted across requests,
# uncomment the line :file instead of the default :storage. Otherwise, it will use the default storage as the temp cache store.
config.cache_storage = :file
end
这是更改旧行为的提交:link