Ruby on rails bootsy + cloud image download

I have a RoR project living on heroics. I have bootsy (an editor with image loading functions) and I have a cloud one. Ive setup uploader, keys and initializers for cloud api (can show you if necessary). Now, when I try to upload an image to bootsy - it creates a database row and creates an image in the cloud. But in the js window from bootsy, there is empty <img>

 ruby '2.3.1' gem 'rails', '~> 5.1.1' gem 'bootsy' gem 'carrierwave' gem 'fog' gem 'cloudinary', '~> 1.8.1' 

1) uploaders / bootsy / image_uploader.rb

 module Bootsy class ImageUploader < CarrierWave::Uploader::Base include CarrierWave::MiniMagick # storage Bootsy.storage include Cloudinary::CarrierWave def store_dir "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end version :large do process :eager => true process resize_to_fit: [ 700, 700 ] end version :medium do process :eager => true process resize_to_fit: [ 300, 300 ] end version :small do process :eager => true process resize_to_fit: [ 150, 150 ] end version :thumb do process :eager => true process resize_to_fit: [ 150, 150 ] end def extension_white_list %w(jpg jpeg gif png) end end end 

2) initializers /bootsy.rb

 Bootsy.setup do |config| config.image_versions_available = [:small, :medium, :large, :original] config.storage = :fog end 

3) models / article.rb

 class Article < ApplicationRecord include Bootsy::Container mount_uploader :image, Bootsy::ImageUploader mount_uploader :main_image, ArticleImageUploader mount_uploader :list_image, ArticleImageUploader end 

This is what I have in my browser And html code from validation

PS Well, I really don't know, I'm just repeating this mistake in a public repository. https://bitbucket.org/dekakisalove/bootsy_tes/ I will add generosity to this issue as soon as possible.

+7
ruby-on-rails heroku cloudinary
source share
1 answer

This problem is due to the incorrect return value of the store! method store! class Cloudinary::CarrierWave::Storage

To work around this problem, you can use several options, for example:

like this in config/initializers/cloudinary_store.rb

 module CloudinaryStorage def store!(file) super || uploader.metadata end end ActiveSupport.on_load :after_initialize do Cloudinary::CarrierWave::Storage.prepend CloudinaryStorage end 

or like this in app/uploaders/image_uploader.rb

 module Bootsy class ImageUploader < CarrierWave::Uploader::Base after :store, :reload_data def reload_data(file) model.reload end # etc.. 
+2
source share

All Articles