【发布时间】:2020-03-01 14:58:55
【问题描述】:
我正在按照本教程使用 DropzoneJS 进行多个文件上传,但我不知道如何获取属于模型的多个图像以显示在“显示”页面中。尽管在@post.feature_image 数组中做了.each,但我上传多张图片时只显示一张图片。
示例回购:https://github.com/justalever/drag_and_drop_active_storage
我为使其正常工作所做的更改: _form.html.erb
data-dropzone-max-files="10"
posts/show.html.erb
<%= link_to @post do %>
<% @post.feature_image.each do |image| %>
<%= image_tag image %>
<% end %>
<% end %>
models/post.rb
class Post < ApplicationRecord
belongs_to :user
has_many_attached :feature_image
end
请帮忙——我做错了什么?
【问题讨论】:
标签: javascript ruby-on-rails ruby ruby-on-rails-5