Понадобится:
1) полиморфным вложения ресурсов
2) Рельсы загрузить камень (https://github.com/carrierwaveuploader/carrierwave)
3) JS множественным загрузчиком (https://blueimp.github.io/jQuery-File-Upload/)
4) легко использование 2 & 3 (github.com/tors/jquery-fileupload-rails)
db:
class CreateAttachments < ActiveRecord::Migration
def change
create_table :attachments do |t|
t.string :name
t.string :link
t.integer :attachmentable_id
t.string :attachmentable_type
t.integer :user_id
t.timestamps
end
add_index :attachments, :user_id
add_index :attachments, [:attachmentable_id, :attachmentable_type]
end
end
Контроллер:
class AttachmentsController < ApplicationController
...
def create
@attachment = Attachment.new(params[:attachment])
@attachment.name = params[:attachment][:link].original_filename
if @product_attachment.save
# do something
else
# do something
end
end