Topic: Image display bug in Rails 1.2.1

I tried to display an image uploaded in a MySQL database and that didn't work, therefore I did some tests on two consecutive lines

Line 1   => NO IMAGE "?"

<%= image_tag(url_for(:action => 'picture', :id => picture.id))%>

Line 2   => No Image "?" but when you click on the link image is displayed !!

<%= link_to(image_tag(url_for(:action => 'picture', :id => picture.id)),
url_for(:action => 'picture', :id => picture.id)) %>

When I do the same thing on my laptop with Rails 1.1.6 installed, everything works...

Displaying images stored in the images directory works without any flaws...

** Has anyone experienced a similar problem with image_tag's in Rails 1.2.x ??

** Do you have an alternative way of displaying images that will work under 1.2.1 (with uploading the images to the database) ?

** Is this a formulation bug or a configuration of the server problem (pages are hosted ??

Re: Image display bug in Rails 1.2.1

It's my understanding that it's much better to store images on the filesystem than in a database.  Did you say it's working if you do that?  If so, I recommend you stick with it.

It's interesting to me that #2 wouldn't show the image until you click it.  what is the html that that long string of code generates?

Re: Image display bug in Rails 1.2.1

Thank you very much for your reply...

The suggestion to use images stored in the filesystem, well I thought of it, but when you want to store thousand's of images it can easily become a mess with the file names...

The annoying part is that under Rails 1.1.6 everything works flawlessly...

The HMTL generated is :

<a href="/info/picture/3" onclick="window.open(this.href,'new_window','height=500,width=700');return false;"><img alt="My alt info" src="/info/picture/3.png" width="200" /></a>


Using the following code in the View file :

<%= 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 ) %>

Re: Image display bug in Rails 1.2.1

I checked on my laptop and the HTML output looks like :

<a href="/info/picture/3" onclick="window.open(this.href,'new_window','height=500,width=700');return false;"><img alt="My alt info" src="/info/picture/3.png?" width="200" /></a>

One can notice the "?" after the 3.png...

Re: Image display bug in Rails 1.2.1

I found a way out...

    <%# The nice way (Rails 1.1.6)... %>

         <%#= link_to(image_tag(url_for(:action => 'picture', :id => info.picture_id), :width => "110", :alt => info.picture.label), {:action => "edit_picture", :id => info.picture_id}) %>
   
        <%# The Rails 1.2.1 way !!! %>
   
             <% alt_tag="\""+info.picture.label.to_s+"\"" %>
         <% src_tag="\"/article/picture/"+info.picture_id.to_s+"\?\""%>
         <% href_tag="\"/article/edit_picture/"+ info.picture_id.to_s+"\"" %>
         <a href=<%= href_tag%>><img alt=<%=alt_tag%> src=<%=src_tag%> width="110" /></a>
                       
         <%# Here ends the Rails 1.2.1 way !!! %>