我正在尝试用Refile gem实现多个文件上传。
用户必须能够上传多个文件到锦标赛模型。
在show模板中,我尝试读取所有上传的文档,如下所示:
<% @tournament.documents.each do |doc| %>
<%= link_to @tournament.document_filename, attachment_url(doc, :file) %>
<% end %>但这在视图中给了我一个非常长的链接,就像这样:
/attachments/c569801bbd2a2ca51350ca326ec57e18d0d318e9/store/ad644cadeda8ee5197bc2bb8a66cc966f5b4b74fad7bbccd2ab798a10c98/file有没有办法输出上传文档的文件名?
非常感谢你的帮助,
安东尼
发布于 2017-03-14 21:10:37
一种更简单的解决方案是在创建记录时存储文件名。将这些列(filename、size、content_type)添加到模型中,Refile将在创建时尝试自动填充它们。
class StoreMetadata < ActiveRecord::Migration
def change
add_column :users, :profile_image_filename, :string
add_column :users, :profile_image_size, :integer
add_column :users, :profile_image_content_type, :string
end
endhttps://stackoverflow.com/questions/35743906
复制相似问题