I have set up my models to use a polymorphic Image model. This is working fine, however I am wondering if it is possible to change the :styles setting for each model. Found some
I've had a similar question when dealing with dynamic behavioral changes on my models. Playing around with irb, I found out that this works:
module Foo
attr_accessor :bar
end
class Bar
extends Foo
end
bar.bar = 'test' # 'test'
bar.bar # 'test'
# also works for instances of Bar!
So i would create an attribute called image_style that could be changed to whatever module you want to add, by using this code on Image initialization:
def after_initialize
if self.image_style?
extend Object.const_get(image_style)
else
extend DefaultImageStyle
end
end
I just wonder if this works with paperclip since the after_initialize method may be called after paperclip does it's magic.. Worth a try though!