如何查询 Active Storage blob 文件名?
基本上是寻找所有不明显的连接快捷方式。
我想通了...
has_one_attached:
class Report < ApplicationRecord
has_one_attached :backup
end
然后就可以查询blob了:
Report.joins(:backup_blob).where("active_storage_blobs.filename LIKE ?", "%query%").count
有_many_attached:
class Report < ApplicationRecord
has_many_attached :backups
end
然后就可以查询blob了:
Report.joins(:backups_blobs).where("active_storage_blobs.filename LIKE ?", "%query%").count
您还可以通过
content_type
、byte_size
和 checksum
查询 blob