-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Paperclip is not compatible with STI #293
Comments
It worked in paperclip 2.3.11 but it was broken in fd6eba3 |
Ha, let me check. |
It appears to be broken for me too. |
There's another issue with STI (or inheritance in general) when calling has_attached_file again on a subclass. Instead of adding an attachment definition to the subclass only, the attachment_definitions hash of the superclass is altered, and therefore it will apply to all subclasses. The superclass' attachment definitions hash is altered here: https://github.com/thoughtbot/paperclip/blob/master/lib/paperclip.rb#L266. This should be something like: |
Yep, I'm experiencing the same troubles as well. |
Yes, this is a real problem, only works with version 2.3.11 |
What do you think? #605 |
Fixed by #605. Please ping me if that's not the case and I will reopen this. |
Waiting for this issue to test it: |
Finally I could test it. It works perfectly. Please release! ;-) |
That's issue is quite old.. Sorry for take it alive again. Just would like to know if, when using STI plus this url config "/system/v/:hash.:extension"... The supercalss :hash will be different from the subclass :hash right? For example: class X < AR::Base
has_attached_file :image,
styles: { thumb: ["175x150", :png] },
url: "/system/v/:hash.:extension",
hash_secret: 'secret'
end
class Y < X
end
class Z < X
end
x = X.find(1) #=> <X type=''>
y = Y.find(2) #=> <Y type='Y'>
z = Z.find(3) #=> <Z type='Z'>
x.image.url #=> '/public/system/v/::::hashX:::' # ok, that's expected
# :(, The image file was created with the X hash..
# But when I try to retrive the url form y instance the url is generated with the Y hash.
y.image.url #=> '/public/system/v/::::hashY:::'
z.image.url #=> '/public/system/v/::::hashZ:::' # :( The image file, from Y and Z instances was created using the X hash. Any thoughts? thanks! |
Paperclip is completely uncompatible with Single Table inheritance.
We have the following architecture in our project:
In this case papelclip populates all validation across all three models which is incorrect.
This behavior also will occur for multiple attachments definishions because they are writen using:
def attachment_definitions
read_inheritable_attribute(:attachment_definitions)
end
The text was updated successfully, but these errors were encountered: