簡體   English   中英

生產后創建/更新后的Cloudinary反向照片順序

[英]Cloudinary reverse photos order after create/update on production

我正在使用cloud附屬寶石上傳將在旋轉木馬上展出的照片,這對我來說很重要。

更新:

發生的事情是,當我們打電話時:

product = Product.find(id)
product.photo.count # it returns many photos from attachinary
> 12
first_photo = product.photo.first 

在生產中:

  • first_photo返回最后創建的照片(更大的ID號)

在開發/分期中:

  • first_photo返回創建的第一張照片(較小的ID號)

Atachinary創建此表:

  create_table "attachinary_files", force: :cascade do |t|
    t.string   "attachinariable_type"
    t.integer  "attachinariable_id"
    t.string   "scope"
    t.string   "public_id"
    t.string   "version"
    t.integer  "width"
    t.integer  "height"
    t.string   "format"
    t.string   "resource_type"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.index ["attachinariable_type", "attachinariable_id", "scope"], name: "by_scoped_parent", using: :btree
  end

眼鏡:

  • Rails:5.0.1
  • 附件:1.3.1
  • Cloudinary:1.1.1

  • 制品
  • 附屬領域:照片

Product.rb

has_attachments :photo, maximum: 20, accept: [:jpg, :jpeg, :jfif, :bmg, :bpg, :png]

我們可以通過在我們需要顯示照片的所有時間添加id來進行轉換。 在產品#edit視圖中,我們可以看到在我的情況下,附加順序的小圖片在生產中仍然“反轉”,但我認為這不是一個主要問題,因為我們有id來跟蹤正確的順序。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM