# Image\_tag and Rails 1.2.1

**URL:** <https://www.ruby-forum.com/t/image-tag-and-rails-1-2-1/83677>\
**Category:** Rails\
**Created:** [January 28, 2007, 7:01pm UTC](https://www.ruby-forum.com/t/image-tag-and-rails-1-2-1/83677 "2007-01-28T19:01:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jabo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aeb1de/32.png) [@jabo](https://www.ruby-forum.com/u/jabo)\
**Post date:** [January 28, 2007, 7:01pm UTC](https://www.ruby-forum.com/t/image-tag-and-rails-1-2-1/83677/1 "2007-01-28T19:01:40Z")

</div>

The following code from the view worked in Rails 1.1.6

\<%= image\_tag(url\_for(:action =\> ‘picture’, :id =\> article.picture\_id),  
:size =\> “110x”, :alt =\> article.picture.label) %\>

Now it does not work anymore (under Rails 1.2.1) : What is wrong ??

HTML code generated :  
1.1.6  
 ![Alt label](https://www.ruby-forum.com/article/picture/3.png?)  
1.2.1  
 ![Alt label](https://www.ruby-forum.com/news/picture/3.png)

There seems to be a difference, what to do ??

---

<div class="post-metadata">

**Author:** ![jabo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aeb1de/32.png) [@jabo](https://www.ruby-forum.com/u/jabo)\
**Post date:** [January 28, 2007, 9:10pm UTC](https://www.ruby-forum.com/t/image-tag-and-rails-1-2-1/83677/2 "2007-01-28T21:10:37Z")

</div>

Ja Bo :

> 1.2.1  
> ![Alt label](https://www.ruby-forum.com/news/picture/3.png)
> 
> There seems to be a difference, what to do ??

Hi,

Suppose the image height is 50 px.

You can write :

\<%= image\_tag(url\_for(:action =\> ‘picture’, :id =\> article.picture\_id),  
:size =\> “110x50”, :alt =\> article.picture.label) %\>

or :

\<%= image\_tag(url\_for(:action =\> ‘picture’, :id =\> article.picture\_id),  
:width =\> “110”, :height =\> ‘50’, :alt =\> article.picture.label) %\>

– Jean-François.

–  
À la renverse.

---

<div class="post-metadata">

**Author:** ![jabo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aeb1de/32.png) [@jabo](https://www.ruby-forum.com/u/jabo)\
**Post date:** [January 28, 2007, 11:45pm UTC](https://www.ruby-forum.com/t/image-tag-and-rails-1-2-1/83677/3 "2007-01-28T23:45:45Z")

</div>

Somehow the image is not displayed on the screen, tried your settings  
but nothing helps…

---

<div class="post-metadata">

**Author:** ![jabo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aeb1de/32.png) [@jabo](https://www.ruby-forum.com/u/jabo)\
**Post date:** [January 29, 2007, 8:12pm UTC](https://www.ruby-forum.com/t/image-tag-and-rails-1-2-1/83677/4 "2007-01-29T20:12:47Z")

</div>

I did the following test :

TEST 1 =\> DOESN’T WORK !!!  
\<%= image\_tag(url\_for(:action =\> ‘picture’, :id =\> picture.id))%\>

TEST 2 =\> DOESN’T WORK !!!  
\<%= link\_to(image\_tag(url\_for(:action =\> ‘picture’, :id =\> picture.id)),  
url\_for(:action =\> ‘picture’, :id =\> picture.id)) %\>

TEST 3 =\> POP-UP SHOWS IMAGE !! — IMAGE TAG DOESN’T SHOW THE SAME  
IMAGE !!!  
\<%= link\_to(image\_tag(url\_for(:action =\> ‘picture’, :id =\> picture.id),  
:width =\> “200”, :alt =\> picture.label), url\_for(:action =\> ‘picture’,  
:id =\> picture.id), :popup=\>true ) %\>

What can be the reason for this,

Rails 1.2.1 bug ??

---

<div class="post-metadata">

**Author:** ![jabo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aeb1de/32.png) [@jabo](https://www.ruby-forum.com/u/jabo)\
**Post date:** [January 29, 2007, 9:03pm UTC](https://www.ruby-forum.com/t/image-tag-and-rails-1-2-1/83677/5 "2007-01-29T21:03:25Z")

</div>

Ja Bo wrote:

> HTML code generated :  
> 1.1.6  
> ![Alt label](https://www.ruby-forum.com/article/picture/3.png?)  
> 1.2.1  
> ![Alt label](https://www.ruby-forum.com/news/picture/3.png)

Not sure about the width disappearing, but you also seem to have  
different controllers – “article” vs “news”. You might try either  
specifying a controller in “url\_for” or checking your routes.

Asa

---

<div class="post-metadata">

**Author:** ![jabo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aeb1de/32.png) [@jabo](https://www.ruby-forum.com/u/jabo)\
**Post date:** [January 29, 2007, 10:01pm UTC](https://www.ruby-forum.com/t/image-tag-and-rails-1-2-1/83677/6 "2007-01-29T22:01:48Z")

</div>

Sorry but that was a mistake when i retyped, in reality they are exactly  
the same…

See my other example :

TEST 1 =\> DOESN’T WORK !!!  
\<%= image\_tag(url\_for(:action =\> ‘picture’, :id =\> picture.id))%\>

TEST 2 =\> DOESN’T WORK !!!  
\<%= link\_to(image\_tag(url\_for(:action =\> ‘picture’, :id =\> picture.id)),  
url\_for(:action =\> ‘picture’, :id =\> picture.id)) %\>

TEST 3 =\> POP-UP SHOWS IMAGE !! — IMAGE TAG DOESN’T SHOW THE SAME  
IMAGE !!!  
\<%= link\_to(image\_tag(url\_for(:action =\> ‘picture’, :id =\> picture.id),  
:width =\> “200”, :alt =\> picture.label), url\_for(:action =\> ‘picture’,  
:id =\> picture.id), :popup=\>true ) %\>

Here I have copy pasted from one view file… and I have put the three  
one below another, so they have access to exactly the same  
information… !!!

Asa H. wrote:

> different controllers – “article” vs “news”. You might try either

> Asa
