Image_tag and Rails 1.2.1

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
1.2.1
Alt label

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

Ja Bo :

1.2.1
Alt label

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.

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

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 ??

Ja Bo wrote:

HTML code generated :
1.1.6
Alt label
1.2.1
Alt label

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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs