我可以在Active Admin中的一列中显示图像文件名,但似乎无法显示实际的图像。
我有一个关系,其中
Member
has_many :member_images
MemberImage
belongs_to :member
我可以成功上传图片,所有关联都已经就位。
因此,为了显示文件名,我会这样做:
column "Filename" do |f|
f.member_images.map(&:photo_file_name).join("<br />").html_safe
end
我尝试过这样做来显示实际图像
column "Images" do |m|
m.member_images do |img|
image_tag(img.photo.url(:thumb))
end
end
但是我在视图中遇到了这个错误。
<ActiveRecord::Associations::CollectionProxy::ActiveRecord_Associations_CollectionProxy_MemberImage:0x007f9634a3f760>
请问有人能告诉我我做错了什么吗?
谢谢!
编辑
我添加了一个.each,这样我就可以遍历每个图像了,但现在我会看到以下内容:
[#<MemberImage id: 1, member_id: 1, created_at: "2014-02-18 20:28:33", updated_at: "2014-02-18 20:28:33", photo_file_name: "associations.jpg", photo_content_type: "image/jpeg", photo_file_size: 140780, photo_updated_at: "2014-02-18 20:28:33">]
each
改为map
。 - Roman Kiselenkopaperclip
,但我看到正确的 HTML 标签,尝试打开src
链接中的图像?图像可用于link_to_bucket/images/member_images/2/thumb.jpg
。 - Roman Kiselenko