Cloudinary仅在本地工作,不在生产中

时间:2018-11-15 11:52:12

标签: ruby-on-rails heroku storage cloudinary

我在Heroku上部署我的应用程序时遇到问题...自从尝试在我的Heroku应用程序中使用Cloudinary以来已经有几个小时了。

我遵循了与Cloudinary完全不同的教程。

编辑 当我在本地应用程序上下载照片时,可以在Cloudinary上找到它们!如何在我的Heroku应用程序上也进行制作? :/

宝石文件

# paperclip
gem 'paperclip'
gem 'paperclip-cloudinary'

config / cloudinary.yml

production:
  cloud_name: hoxr8ugj3
  api_key: 'xxx'
  api_secret: xxxx
  enhance_image_tag: true
  static_image_support: true

models / photo.rb

class Photo < ApplicationRecord
    belongs_to :projet

    has_attached_file :image, :styles => { :medium => "300x300>", :thumb => "100x100>" }
    validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/ 
  end

config / environments / production.rb

  Paperclip::Attachment.default_options.merge!({
    :storage => :cloudinary,
    :path => ':id/:style/:filename'
  })

一切在本地都能正常运行...我不明白! :(

使用git push heroku master,我收到此警告You set your config.active_storage.service to :local in production.

我可能需要更改storage.yml中的某些内容?还是创建secret.yml?但是如何?

storage.yml

test:
  service: Disk
  root: <%= Rails.root.join("tmp/storage") %>

local:
  service: Disk
  root: <%= Rails.root.join("storage") %>

我也尝试过:

heroku config:add CLOUDINARY_URL=....

heroku记录错误:

ate (1.5ms)  INSERT INTO "photos" ("projet_id", "created_at", "updated_at", "image_file_name", "image_content_type", "image_file_size", "image_updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING "id"  [["projet_id", 1], ["created_at", "2018-11-15 12:07:04.278472"], ["updated_at", "2018-11-15 12:07:04.278472"], ["image_file_name", "zenploylogo.png"], ["image_content_type", "image/png"], ["image_file_size", 21847], ["image_updated_at", "2018-11-15 12:07:03.988840"]]
2018-11-15T12:07:04.443055+00:00 app[web.1]: D, [2018-11-15T12:07:04.442918 #4] DEBUG -- : [5e1f39fa-7d71-4b07-bc23-2696425689d8]    (1.0ms) ROLLBACK
2018-11-15T12:07:04.443536+00:00 app[web.1]: I, [2018-11-15T12:07:04.443455 #4]  INFO -- : [5e1f39fa-7d71-4b07-bc23-2696425689d8] Completed 500 Internal Server Error in 523ms (ActiveRecord: 9.6ms)
2018-11-15T12:07:04.444215+00:00 app[web.1]: F, [2018-11-15T12:07:04.444142 #4] FATAL -- : [5e1f39fa-7d71-4b07-bc23-2696425689d8]
2018-11-15T12:07:04.444288+00:00 app[web.1]: F, [2018-11-15T12:07:04.444211 #4] FATAL -- : [5e1f39fa-7d71-4b07-bc23-2696425689d8] KeyError (key not found: :ciphers):
2018-11-15T12:07:04.444339+00:00 app[web.1]: F, [2018-11-15T12:07:04.444280 #4] FATAL -- : [5e1f39fa-7d71-4b07-bc23-2696425689d8]
2018-11-15T12:07:04.444393+00:00 app[web.1]: F, [2018-11-15T12:07:04.444338 #4] FATAL -- : [5e1f39fa-7d71-4b07-bc23-2696425689d8] app/controllers/projets_controller.rb:63:in `block in update'

非常感谢您的帮助,对不起我的英语。

1 个答案:

答案 0 :(得分:0)

此问题与Cloudinary gem更新至1.10.0中的错误有关。参见https://github.com/cloudinary/cloudinary_gem/issues/322