【问题标题】:Unable to update images on articles无法更新文章的图片
【发布时间】:2019-09-28 11:56:05
【问题描述】:

我正在使用carrierwave 和cloudinary gems 在我的文章模型上附加图像。创建功能正常,但是当我需要更新现有图像时,出现以下错误:

“image/upload/v1557497204/hqef7unyuvfsva933idv.jpg”的'未定义方法`reject':String'。

但是,如果我返回并刷新文章页面,新图像就在那里

def update
        @article = Article.find(params[:id]) 
        if @article.update(article_params)#the error raised here
            flash[:notice] = "Your Article was Created"
            redirect_to @article
        else
            render 'edit'
        end
    end

【问题讨论】:

  • 您的模型或上传器中更有可能出现该错误。请至少发布模型
  • 这是多张图片上传吗?你要上传多少张图片?你看到了多少张图片?
  • @VeridianDynamics 是的,是多张图片上传。 Model has_many :comments , dependent: :destroy mount_uploaders :image, ImageUploader serialize :image, JSON Up loader ```` class ImageUploader
  • 不幸的是,我认为你是 SOL。我刚刚根据 Cloudinary 的 gem 存储库发布了我的回复。

标签: ruby-on-rails carrierwave cloudinary


【解决方案1】:

这很可能是由一个已知​​问题引起的:https://github.com/cloudinary/cloudinary_gem/issues/266

目前看来,上传多张图片的问题尚未解决。

【讨论】:

  • 是的,该论坛在第一条评论下方列出了一个:github.com/taragano/Cloudinary_multiple_uploads。但是,我不建议您为了保持 Cloudinary 而努力工作。它们比替代方案贵:AWS S3 存储桶。尽管 AWS 可能会让人感到有些困惑,但我认为它们是 Cloudinary 的更便宜、更简单的替代品(我在 4 年前迁移了我的 Rails 应用程序并且从未回头!)
猜你喜欢
  • 2018-04-26
  • 2017-10-22
  • 1970-01-01
  • 1970-01-01
  • 2021-09-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多