Search code examples
ruby-on-railspaperclipcarrierwaveattachment-furails-admin

Multiple Image Uploads with rails_admin (Attachment_fu, Carrierwave, etc.)? Any solutions?


I'm looking for a easy way to have multiple attachments on one model using Rails Admin. I've already Paperclip working, but I need multiple images and not just one.

Any hints / ideas / links?

Thank you very much!

Ole


Solution

  • Let's say that you have a user who wants many photos:

    class User
      has_many :photos
    end
    
    class Photo
      belongs_to :user
      has_attached_file :image
      #or
      mount :image, ImageUploader
    end
    

    So you don't ask your carrierwave or paperclip model to have multiple files, you instead have many paperclip models belonging to your rails model.