简体   繁体   中英

Cloudinary only works locally and not in production

I have a problem with deploying my app on heroku ... it's been several hours since I tried to use Cloudinary with my Heroku app.

I followed literally different tutorials from Cloudinary.

EDIT When I download photos on my local app, i find them on Cloudinary ! How to make it also on my Heroku app ? :/

Gemfile

# 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'
  })

Everything works perfectly locally ... I do not understand! :(

With git push heroku master , i get this warning You set your config.active_storage.service to :local in production.

I probably need to change some things in storage.yml ? or create secret.yml ? but how ?

storage.yml

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

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

I also tried :

heroku config:add CLOUDINARY_URL=....

heroku logs error :

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'

Thank you very much for your help and sorry for my english.

This issue has to do with a bug in the Cloudinary gem update to 1.10.0. See https://github.com/cloudinary/cloudinary_gem/issues/322

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM