mongoid-paperclip icon indicating copy to clipboard operation
mongoid-paperclip copied to clipboard

Using parent ids in the embedded document path for an attachment

Open Vrael opened this issue 9 years ago • 0 comments

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.

Vrael avatar Jul 05 '15 11:07 Vrael