Skip to content

Instantly share code, notes, and snippets.

@seamusjr
Created August 14, 2011 21:47
Show Gist options
  • Save seamusjr/1145350 to your computer and use it in GitHub Desktop.
Save seamusjr/1145350 to your computer and use it in GitHub Desktop.
loop collection images paperclip
<% for asset in @post.assets %>
<li><%= link_to image_tag(asset.asset.url(:thumb)), asset.asset.url(:original) %></li>
<% end %>
@rmagnum2002
Copy link

undefined method `assets' for nil:NilClass

Extracted source (around line #12):

9:


10:

<% link_to post.title, post_path(post) %>


11:
12: <% for asset in @post.assets %>
13:
14:
  • <%= link_to image_tag(asset.asset.url(:thumb)), asset.asset.url(:original) %>

  • 15:

    please help

    @rmagnum2002
    Copy link

    ok, sorry. that code was only for show.html.erb

    but I am trying to view images in index.html.erb, how to do this? thanks, and thanks for your screencast, it's really good

    one more thing, how can I limit the uploaded images? For ex. if I upload 5 images and then edit that post, I can upload another 5 images, and I end up having 10 images per post.
    Thanks for this one too.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment