# How to make a picture a linked picture

**URL:** <https://www.ruby-forum.com/t/how-to-make-a-picture-a-linked-picture/172095>\
**Category:** Rails\
**Created:** [July 14, 2009, 7:26pm UTC](https://www.ruby-forum.com/t/how-to-make-a-picture-a-linked-picture/172095 "2009-07-14T19:26:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![miss\_moviestar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ecae2f/32.png) [@miss\_moviestar](https://www.ruby-forum.com/u/miss_moviestar)\
**Post date:** [July 14, 2009, 7:26pm UTC](https://www.ruby-forum.com/t/how-to-make-a-picture-a-linked-picture/172095/1 "2009-07-14T19:26:58Z")

</div>

hi  
i want to get a picture and a linke as inputs from user and then when  
user clicked on that picture it goes to that link related to the picture  
do anyone know how?  
thanks in advance

---

<div class="post-metadata">

**Author:** ![miss\_moviestar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ecae2f/32.png) [@miss\_moviestar](https://www.ruby-forum.com/u/miss_moviestar)\
**Post date:** [July 14, 2009, 7:53pm UTC](https://www.ruby-forum.com/t/how-to-make-a-picture-a-linked-picture/172095/2 "2009-07-14T19:53:16Z")

</div>

Ghazal M. wrote:

> hi  
> i want to get a picture and a linke as inputs from user and then when  
> user clicked on that picture it goes to that link related to the picture  
> do anyone know how?  
> thanks in advance

\<%= link\_to image\_tag( ‘img1.jpg’ ), :action =\> ‘action\_to\_perform’ %\>

---

<div class="post-metadata">

**Author:** ![miss\_moviestar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ecae2f/32.png) [@miss\_moviestar](https://www.ruby-forum.com/u/miss_moviestar)\
**Post date:** [July 14, 2009, 7:58pm UTC](https://www.ruby-forum.com/t/how-to-make-a-picture-a-linked-picture/172095/3 "2009-07-14T19:58:48Z")

</div>

Shandy N. wrote:

> \<%= link\_to image\_tag( ‘img1.jpg’ ), :action =\> ‘action\_to\_perform’ %\>

Or, if you want to use a link\_to\_remote:

\<%= link\_to\_remote image\_tag( ‘img1.jpg’ ), :url =\> {  
:action =\> ‘action\_to\_perform’}, :update =\> ‘update\_div’ %\>

I use similar code a lot as a user interface where you don’t want  
another page to load. For example, if I needed to turn a value on or off  
I would do something like:

\<%= link\_to\_remote image\_tag( @user.active ? ‘chexk.jpg’ : ‘ex.jpg’ ),  
:url =\> {:action =\> ‘action\_to\_perform’, :id =\> @user.id},  
:update =\> ‘update\_div’ %\>

---

<div class="post-metadata">

**Author:** ![miss\_moviestar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ecae2f/32.png) [@miss\_moviestar](https://www.ruby-forum.com/u/miss_moviestar)\
**Post date:** [July 16, 2009, 5:56pm UTC](https://www.ruby-forum.com/t/how-to-make-a-picture-a-linked-picture/172095/4 "2009-07-16T17:56:12Z")

</div>

Shandy N. wrote:

> Shandy N. wrote:
> 
> > \<%= link\_to image\_tag( ‘img1.jpg’ ), :action =\> ‘action\_to\_perform’ %\>
> 
> Or, if you want to use a link\_to\_remote:
> 
> \<%= link\_to\_remote image\_tag( ‘img1.jpg’ ), :url =\> {  
> :action =\> ‘action\_to\_perform’}, :update =\> ‘update\_div’ %\>
> 
> I use similar code a lot as a user interface where you don’t want  
> another page to load. For example, if I needed to turn a value on or off  
> I would do something like:
> 
> \<%= link\_to\_remote image\_tag( @user.active ? ‘chexk.jpg’ : ‘ex.jpg’ ),  
> :url =\> {:action =\> ‘action\_to\_perform’, :id =\> @user.id},  
> :update =\> ‘update\_div’ %\>

thanks but when i use this:  
\<%= link\_to image\_tag(advertise.public\_filename(:thumb)) , :action =\>  
advertise.link%\>

it says No route matches “/advertises/www.cars.com” with {:method=\>:get}  
how should i use it so it open a page for me and take me to address of  
that link?
