# Paperclip polymorfic problem with :styles

**URL:** <https://www.ruby-forum.com/t/paperclip-polymorfic-problem-with-styles/191249>\
**Category:** Rails\
**Created:** [July 8, 2010, 8:53am UTC](https://www.ruby-forum.com/t/paperclip-polymorfic-problem-with-styles/191249 "2010-07-08T08:53:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dries](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/8e8cbc/32.png) [@dries](https://www.ruby-forum.com/u/dries)\
**Post date:** [July 8, 2010, 8:53am UTC](https://www.ruby-forum.com/t/paperclip-polymorfic-problem-with-styles/191249/1 "2010-07-08T08:53:26Z")

</div>

I made a model Picture that is polymorfic but I want to specify  
specific :styles for each model that use Picture.

[http://pastie.org/1034662](http://pastie.org/1034662)

I don’t know how to this, I used lambda for this but he doesn’t know  
the data.instance.picturable on submit. It returns always nil.

---

<div class="post-metadata">

**Author:** ![dries](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/8e8cbc/32.png) [@dries](https://www.ruby-forum.com/u/dries)\
**Post date:** [July 8, 2010, 6:14pm UTC](https://www.ruby-forum.com/t/paperclip-polymorfic-problem-with-styles/191249/2 "2010-07-08T18:14:56Z")

</div>

> I made a model Picture that is polymorfic but I want to specify  
> specific :styles for each model that use Picture.
> 
> [http://pastie.org/1034662](http://pastie.org/1034662)
> 
> I don’t know how to this, I used lambda for this but he doesn’t know  
> the data.instance.picturable on submit. It returns always nil.

My memory is that you can’t do this. The has\_attachment code gets  
evaluated long before any specific model associations are present. And  
the style definitions aren’t lazily loaded. Or something.

In any event I tried to do something similar to what you’re doing and it  
doesn’t work.

-philip
