开发中使用sqlite3进行CarrierWave多个文件上传的解决方法 [英] Workaround for CarrierWave multiple file upload using sqlite3 in development

查看:49
本文介绍了开发中使用sqlite3进行CarrierWave多个文件上传的解决方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的团队开发环境中,我们使用的是Rails中默认的sqlite3。

In my team development environment, we are using sqlite3 which comes default in Rails.

但是,carrierwave的多文件上传实现需要支持array / json数据类型的数据库

However, carrierwave's implementation of multi files upload require database that supports array/json datatype.

是否有任何解决方法,以便它可以在我们的开发环境中运行而无需安装其他数据库(如postgres)?

Are there any workaround so that it will work on our development environment without installing other database such as postgres?

我正在按照此处的说明进行操作 https://github.com/carrierwaveuploader/carrierwave #multiple-file-uploads

I'm following the instructions over here https://github.com/carrierwaveuploader/carrierwave#multiple-file-uploads

推荐答案

唯一可行的解​​决方法是为上传创建单独的模型:

The only possible workaround would be to create a separate model for the uploads:

class ImagesContainer
  has_many :uploads
end

class Upload
  mount_uploader :image, ImageUploader

  belongs_to ImagesContainer
end

这篇关于开发中使用sqlite3进行CarrierWave多个文件上传的解决方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆