What is the best way to handle multiple attachments in rails projects?
I have a post. I want to attach different kinds of content (audio/document/photo/video) and display them.
I want to be able to use same attachments in different posts.
How I should implement this (if i use gem carrierwave, for example)?
This works, but i’d like to separate each kind of content to different models and tables (there will be lots of content):
class Attachment < ActiveRecord::Base
attr_accessible :post_id, :image, :remote_image_url, :document, :remote_document_url, :video, :remote_video_url
belongs_to :post
belongs_to :user
mount_uploader :image, ImageUploader
mount_uploader :document, DocumentUploader
mount_uploader :video, VideoUploader
end
*UPDATED
You can create a model Content (which you can associate to whatever model you like later) then do a has_many with nested Content model to add multiple Content items. Dont forget to whitelist your extensions and MIME-types