如何访问 rails 中的 cloudinary 属性?

How to access cloudinary attributes in rails?

给定来自表单的 f.object.filename.inspect 的以下输出。我正在使用 carrierwave.

$> <CarPhotoUploader:0x007f83efa788f0 
    @model=#<CarPhoto id: 19, filename: "image/upload/v1433056939/eio6d7b0dtfdjptmxud4.png", car_id: 19, document: nil, created_at: "2015-05-31 07:22:04", updated_at: "2015-05-31 07:26:45">, 
    @mounted_as=:filename, 
    @transformation={}, 
    @file=#<Cloudinary::CarrierWave::CloudinaryFile:0x007f83efa786e8 
        @uploader=#<CarPhotoUploader:0x007f83efa788f0 ...>, 
    @identifier="image/upload/v1433056939/eio6d7b0dtfdjptmxud4.png", 
    @resource_type="image", 
    @storage_type="upload", 
    @version="1433056939", 
    @filename="eio6d7b0dtfdjptmxud4.png", 
    @public_id="eio6d7b0dtfdjptmxud4", 
    @format="png">, 
    @stored_public_id="eio6d7b0dtfdjptmxud4", 
    @public_id="eio6d7b0dtfdjptmxud4", 
    @stored_version="1433056939", 
    @original_filename="eio6d7b0dtfdjptmxud4.png">

我需要访问 @public_id,但是当我访问

时,除了 nil,我什么也得不到

f.object.filename.public_id.

我该怎么办?

f.object.filename.public_id gives nil.

因为他们就是这样实施的。看看那里 source code.

你要的是my_public_id

所以工作代码是:f.object.filename.my_public_id