In the CMS of the site that I create, I use Paperclip to handle file uploads. Users can upload images and must give each image a brief description, which is then used to indicate the image (for SEO) and for the alt tag. Each image is resized to several predefined sizes and stored on S3.
The user can use this image in several places, effectively creating several different types of models, each of which refers to a particular image.
Therefore, given that I need to store metadata about the image (its description), and I need to share one image between several models, it seems to make sense to encapsulate the image in its own model, which can then be added as an association to any models that are in it need it. Then the Image
model has an attached clip file. This means that I do not need to store duplicate information on any models related to the image.
My concern is one of the results. Instead of removing the URL directly as an attribute, any image requests should now go through the Image
model.
Is this a smart decision or should I take it differently?
source share