With paperclip, how can I change the image location to a “:parent_model_id/:id” folder format?

前端 未结 3 1534
太阳男子
太阳男子 2021-02-06 07:42

Given that I have a Listing model that has many images and each image has one attachment, how can I have the

3条回答
  •  臣服心动
    2021-02-06 07:55

    Since you've got a belongs_to relationship on your Image model, you should just be able to use listing_id as part of the paperclip config:

    has_attached_file :photo, 
        :styles => { :medium => "300x300>", :thumb => "100x100>" }, 
        :url => "system/photos/:listing_id/:id"
    

提交回复
热议问题