How to store an array of images in Rails 3?
I have a model Book that has n screenshots.
Each screenshot is an image.
I would like 开发者_如何学JAVAto use a image plugin (e.g. paperclip)
Can I store a paperclip image in an array and serialize?
Is there a better way?
Thanks
You should probably create a table and model for each Screenshot
and then set up a has_many
relationship from Book
to Screenshot
, and a belongs_to
from Screenshot
to Book
.
Then Screenshot
would use the paperclip plugin to handle the attachment in whatever way you like, though I recommend storing it either on the filesystem or on something like Amazon's S3, both of which the plugin should help you do. Whatever you do, don't store them in the database as it's horribly inefficient and doesn't let you take advantage of fast file servers like Apache, Nginx, or S3.
精彩评论