mongoid-paperclip
mongoid-paperclip copied to clipboard
Using parent ids in the embedded document path for an attachment
I want save an attachment in a path such as:
rails_root/parent/:id_parent/child/:id_child/:filename
class Parent
include Mongoid::Document
embeds_many :childrens , cascade_callbacks: true
end
class Child
include Mongoid::Document
include Mongoid::Paperclip
embedded_in :parent, inverse_of: :childrens
has_mongoid_attached_file :photo,
path: "parent/:id_parent/child/:id/:filename"
end
How can I use :id_parent? Because right now is undefined and it should have parent ids value.