0

I am trying to upload multiple images but after selecting multiple images refile creating only one record. I have checked out gorails refile video from there they shown upload through adding image_id to table. But here refile multiple file uploads

they are working with Image model.

Can anyone help me on this?

here is my code:

My model

class Photo < ActiveRecord::Base acts_as_votable attachment :image has_many :users has_many :images end

My controller params

def photo_params params.require(:photo).permit(:photo_title, :photo_description,:photo_caption, :image, :image_cache_id, :remove_image,) end

Photo form view

<%= f.attachment_field :image, direct: true, multiple: true %>

1 Answers1

0

I can't comment ( not enough reputation ) but you need to go through the refile gem README in more detail. Your models and contoller are not set up to allow multiple file uploads.

E.g you should have (image_files: []) in your strong parameters...

In your Photo model... accepts_attachments_for :images, attachment: :file

An image model like so....

  class Image < ActiveRecord::Base
    belongs_to :photo
    attachment :file
  end

Its all in the README.