I'm using Refile with Rails 4. I'm following their tutorial for multiple image upload. Each Post can have multiple Images. My models look like this:
Post.rb:
has_many :images, dependent: :destroy
accepts_attachments_for :images, attachment: :file
Image.rb:
belongs_to :post
attachment :file
I can upload files, fine by using:
<%= f.attachment_field :images_files, multiple: true, direct: true, presigned: true %>
but when I try to retrieve an image like:
<%= attachment_image_tag(@post.images, :file, :small) %>
I get the error:
undefined method file for #<Image::ActiveRecord_Associations_CollectionProxy:0x007fbaf51e8ea0>
How can I retrieve an image with refile using multiple image upload?
@post.images.inspect
, I get an association with each object having the file nil, and the file_id set to the presigned, so I think that's part working fine. It's just when I try to view the image that it errors. – Bearce@post
? Is it a single record or a collection of records ? Please post the code for@post
. – Edgewise#<Post id: 2, name: "RefileTest", created_at: "2015-07-04 23:54:00", updated_at: "2015-07-04 23:54:00"
– Henceforward