# Link\_to\_remote with image\_tag using Paperclip

**URL:** <https://www.ruby-forum.com/t/link-to-remote-with-image-tag-using-paperclip/178624>\
**Category:** Rails\
**Created:** [November 8, 2009, 6:34am UTC](https://www.ruby-forum.com/t/link-to-remote-with-image-tag-using-paperclip/178624 "2009-11-08T06:34:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bluehandtalking](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c4cdca/32.png) [@bluehandtalking](https://www.ruby-forum.com/u/bluehandtalking)\
**Post date:** [November 8, 2009, 6:34am UTC](https://www.ruby-forum.com/t/link-to-remote-with-image-tag-using-paperclip/178624/1 "2009-11-08T06:34:40Z")

</div>

I am creating a layout of images with links.

In Photo model:

has\_attached\_file :mainimg, :styles =\> {:original =\>  
“465x365”, :thumb =\> “80x70”}

In my Front controller:

def index  
@photos = Photo.find(:all)  
@photos = Photo.paginate :per\_page =\> 28, :page =\> params[:page]  
end

In index.dryml:

\<% outer = ‘a’ %\>  
\<% inner = 1 %\>  
\<% @photos.in\_groups\_of(7).each do |photorow| %\>

  
\<% photorow.each do |photo| %\>  

  
\<% link\_to\_remote (image\_tag(photo.mainimg.url(:thumb)),  
:url =\> {:action =\> ‘projects/show’, :id =\> ‘#  
{photo.project\_id}’}) if photo.mainimg? %\> 
 \<% inner += 1 %\> \<% end %\> 
 \<% outer = outer.succ %\> \<% end %\> \<%= will\_paginate @photos, :page\_links =\> false %\>

Evidently image\_tag(photo.mainimg.url(:thumb) is not right, but being  
a novice not sure where I am  
going wrong.

Thanks,

Jet

---

<div class="post-metadata">

**Author:** ![bluehandtalking](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c4cdca/32.png) [@bluehandtalking](https://www.ruby-forum.com/u/bluehandtalking)\
**Post date:** [November 9, 2009, 6:23am UTC](https://www.ruby-forum.com/t/link-to-remote-with-image-tag-using-paperclip/178624/2 "2009-11-09T06:23:12Z")

</div>

Hi Jet Thompson

I have not used Paperclip. But an example usage of  
link\_to\_remote+image\_tag is

link\_to\_remote (image\_tag("/images/cancel.png", {:alt =\> ‘Cancel’,  
:class=\>“classhere”,:title=\>“Cancel”}),{:url =\> { :action =\>  
‘projects/show’, :id =\> “#{photo.project\_id}”}})

Sijo
