How can I rewrite this to avoid duplicate entries?
images.each do |img|
thumbs.each do |th|
html << link_to(image_tag("#{th.url}"), "#{img.url}")
end
end
I want to wrap thumbnail images th.url into links to original images img.url
up:
I’m using a fog gem to get images and thumbs from S3.
They’re files with different prefixes:
storage.directories.get(bucket, :prefix => "thumbs").files
Why not relate your images and thumbnails in some way?
So if your image is called
image_name.jpgyou could have your thumbnail calledthumbs/image_name.jpg.If your names are unconnected, then why not just associate them in your application so you use an associative array of images and thumbnail names?
Either of those ways enable you to just find the corresponding thumbnail for each image.