Rails 5.1 和 Cloudinary:图像文件无效



我正在Rails 5.1.1中制作的应用程序中使用Heroku,该应用程序使用Cloudinary等图像服务器和atacchinary来上传它。

这是我第一次将 attachinary 与 rails 5 一起使用,当我上传带有输入<%= f.attachinary_file_field :image_event %>的图像时,它工作正常。图像已上传,我可以在云仪表板上看到它。

问题是:当我要创建信息时,它会返回以编辑 crud 中的信息,并在文件输入中出现错误。

说:图像文件无效

我认为这是有关联的,因为图像已上传,但我不确定。该错误发生在开发和生产中。

该字段已在控制器上的必需参数中

development:
  cloud_name: xxxxxxxxxxxxx
  api_key: 'xxxxxxxxxxxxx'
  api_secret: xxxxxxxxxxxxx
  enhance_image_tag: false // changed to false to work with rails 5
  static_image_support: false
production:
  cloud_name: xxxxxxxxxxxxx
  api_key: 'xxxxxxxxxxxxx'
  api_secret: xxxxxxxxxxxxx
  enhance_image_tag: false
  static_image_support: false
test:
  cloud_name: xxxxxxxxxxxxx
  api_key: 'xxxxxxxxxxxxx'
  api_secret: xxxxxxxxxxxxx
  enhance_image_tag: true
  static_image_support: true

我的模特活动:

  has_attachment  :image_event, accept: [:jpg, :png, :gif]

该错误表明,当通过 Attachinary 包含图像时,ORM 可能未正确设置。确保通过将以下行添加到您的 application.rb 文件(或自定义初始值设定项(来包含您希望使用的特定 ORM:

例如

require "attachinary/orm/YOUR_ORM" # active_record or mongoid
有关

这方面的更多信息可以在这里找到:https://github.com/assembler/attachinary#installation

最新更新