I have several models that include Paperclip::Glue and have similar has_attached_file :image
code.
What is a good way of sharing the code?
I created a module, and got Exception encountered: #<NoMethodError: undefined method 'class_attribute' for AttachedImage:Module>
exception.
What does this mean?
I tried creating a common base model that the other models could inherit from:
class PaperclipImage
include Paperclip::Glue
include MongoMapper::Document
STYLES = {}
image_path = ''
has_attached_file :image,
:styles => self::STYLES,
:path => %w( development test ).include?( ENV[ 'RACK_ENV' ]) ? "public/#{ image_path }/:style/:id/:basename.:extension" : "#{ image_path }/:style/:id/:basename.:extension",
...
```
The subclasses have their own image_path, such as `image_path = 'images'`.
But this always uses the base class image_path, instead of the image_path of the subclass.
I tried the same approach with constants: `IMAGE_PATH` and `#{ self::IMAGE_PATH }` which has the same results, even though Ruby does apparently use the subclass constant: http://stackoverflow.com/questions/13234384/in-ruby-is-there-a-way-to-override-a-constant-in-a-subclass-so-that-inherited
So, none of that worked. Is there a good way to share common code across models that include Paperclip::Glue?