开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜