开发者

How do I get multiple paperclip uploads to display in the view?

I'm very new to programming and have followed this screencast at emersonlackey.com on adding multiple paperclip uploads for a record. It all works great but I can't figure out how to display the uploaded images in the records show page.

They display fine on the edit page using:

<%= f.fields_for :venuephotos do |photo| %>
    <% unless photo.object.new_record? %>
      <p>
        <%= link_to image_tag(photo.object.venuephoto.url(:thumb)),开发者_JS百科 photo.object.venuephoto.url(:original) %>
        <%= photo.check_box :_destroy %>
      </p>
    <% end %>
  <% end %>

I've used paperclip in other models but they are the standard each record only has one upload so the images display fine with <%= @model.photo.url %> type call but I cant figure out this other way.

Any help is much apprectiated!


You want to do something like this:

<% for asset in @post.assets %>

  <%= link_to image_tag(asset.asset.url(:thumb)), asset.asset.url(:original) %>

<% end %>

as per the code that goes along with the screencast.

https://github.com/Emerson/Multiple-File-Uploads-with-Paperclip-and-Rails-3/blob/master/app/views/posts/show.html.erb

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜