# Flex\_image has a bug because of class variables/inheritance

**URL:** <https://www.ruby-forum.com/t/flex-image-has-a-bug-because-of-class-variables-inheritance/87100>\
**Category:** Rails\
**Created:** [February 28, 2007, 6:47am UTC](https://www.ruby-forum.com/t/flex-image-has-a-bug-because-of-class-variables-inheritance/87100 "2007-02-28T06:47:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dcarneiro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e36b37/32.png) [@dcarneiro](https://www.ruby-forum.com/u/dcarneiro)\
**Post date:** [February 28, 2007, 6:47am UTC](https://www.ruby-forum.com/t/flex-image-has-a-bug-because-of-class-variables-inheritance/87100/1 "2007-02-28T06:47:27Z")

</div>

FlexImage has a serious bug at the moment because, internally, it stores  
the file\_store value of its file-stored subclasses in a class variable  
@@file\_store

This is what happens as a result:

Say I have two Rails model classes, A and B, that I make subclasses of  
FlexImage. If I set the self.file\_store of each class to two different  
directories. FlexImage will set the SAME file\_store directory for both A  
and B because of the way Ruby currently treats class variables of  
inherited classes as shared across all of them.

I didn’t know how to contact the author of FlexImage so I thought I’d  
post this here.

---

<div class="post-metadata">

**Author:** ![dcarneiro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e36b37/32.png) [@dcarneiro](https://www.ruby-forum.com/u/dcarneiro)\
**Post date:** [April 12, 2007, 9:44pm UTC](https://www.ruby-forum.com/t/flex-image-has-a-bug-because-of-class-variables-inheritance/87100/2 "2007-04-12T21:44:15Z")

</div>

Daniel C. wrote:

> FlexImage has a serious bug at the moment because, internally, it stores  
> the file\_store value of its file-stored subclasses in a class variable  
> @@file\_store
> 
> This is what happens as a result:
> 
> Say I have two Rails model classes, A and B, that I make subclasses of  
> FlexImage. If I set the self.file\_store of each class to two different  
> directories. FlexImage will set the SAME file\_store directory for both A  
> and B because of the way Ruby currently treats class variables of  
> inherited classes as shared across all of them.
> 
> I didn’t know how to contact the author of FlexImage so I thought I’d  
> post this here.

Multi Class Bug Fixed!

[http://beautifulpixel.com/articles/2007/04/12/fleximage\_now\_mulit\_class\_safe](http://beautifulpixel.com/articles/2007/04/12/fleximage_now_mulit_class_safe)
