Closed fuelxc closed 8 years ago
Agree with fuelxc And you can do something like this:
Paperclip.interpolates :id_partition do |attachment, style|
if attachment.instance.ancestors.include? Mongoid::Paperclip
attachment.instance.id.to_s.scan(/.{4}/).join("/")
else
case id = attachment.instance.id
when Integer
("%09d" % id).scan(/\d{3}/).join("/")
when String
id.scan(/.{3}/).first(3).join("/")
else
nil
end
end
end
will break the id partition in non mongoid records
@fuelxc Why should be a non mongoid record at that point? Unless you tell me you want to have mongoid + activerecord, no?!?
I have an app with a need for both.
@fuelxc is there any way to monkey patch like @ASnow did but reusing the code of the paperclip implementation without copy and paste?
@yordis you could alias the method i suppose.
This will be fixed when #64 is merged.
In paperclip 4.2 they already accept strings for the id's
The current implementation will break the id partition in non mongoid records. This fixes that.