Forum: Ruby on Rails Image Display Question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Dave H. (Guest)
on 2006-04-21 00:05
(Received via mailing list)
Hello there,

I have something odd happening to my image tags when displaying an
image.
Here's what my '<img src>' tags are looking like:

<img alt="2-thumb" src="/images/public/uploaded_images/2-thumb.jpg?" />

Notice the question mark at the end of the string. I have no idea where
this
coming from. Here are the important parts of my code:

In the 'image' model:

  DIRECTORY = 'public/uploaded_images'
  def to_url
    return DIRECTORY + "/#{self.id}-thumb.jpg"
  end



In the images_controller:

  def list
    @images = Image.find :all, :order=>"id DESC"
  end



In the list.rhtml view:
<div id="photos">
      <%= render :partial=>'images', :collection=> @images %>
</div>


...and in the partial:
<%= image_tag(images.to_url) %>



It's nothing fancy, but it's driving me nuts trying to figure out where
that
darn question mark is coming from.

Any ideas on this?

Thank you!
Dave hoefler
Jean-François (Guest)
on 2006-04-21 00:17
(Received via mailing list)
2006/4/20, Dave H. <removed_email_address@domain.invalid>:

> I have something odd happening to my image tags when
> displaying an image. Here's what my '<img src>' tags
> are looking like:
>
> <img alt="2-thumb" src="/images/public/uploaded_images/2-
> thumb.jpg?" />
>
> Notice the question mark at the end of the string. I have no idea
> where this
> coming from. Here are the important parts of my code:

I think it comes from that  :

(extract of actionpack CHANGELOG)

* Added automated timestamping to AssetTagHelper methods for
stylesheets, javascripts, and images when Action Controller is run
under Rails [DHH]. Example:

    image_tag("rails.png") # => '<img alt="Rails"
src="/images/rails.png?1143664135" />'

  ...to avoid frequent stats (not a problem for most people), you can
set RAILS_ASSET_ID in the ENV to avoid stats:

    ENV["RAILS_ASSET_ID"] = "2345"
    image_tag("rails.png") # => '<img alt="Rails"
src="/images/rails.png?2345" />'

  This can be used by deployment managers to set the asset id by
application revision

    -- Jean-François.
Dave H. (Guest)
on 2006-04-21 00:26
(Received via mailing list)
Thanks Jean. That clears it up. ;-)

-Dave
This topic is locked and can not be replied to.