With paperclip, how can I change the image location to a ":parent_model_id/:id" folder format?
- by Jamis Charles
Given that I have a Listing model that has many images and each image has one attachment, how can I have the listing_id be part of the folder structure?
Like so: system/photos/[listing_id]/:id
I know that using :id will output the id of the image record.
Here's what I currently have:
class Image < ActiveRecord::Base
belongs_to :listing #Rails ActiveRecord Relation. An image belongs to a post.
# paperclip data
has_attached_file :photo, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :url => "/public/system/:class/:attachment/:id/:style_:filename"
end