Forum: Ruby on Rails problem in: img_options["size"] = img_size

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
C1923672c96592b38c570691547889ee?d=identicon&s=25 sanjay (Guest)
on 2007-05-02 06:17
hi guys,
       I have show_image problem. I have the following code in
application_helper.rb in my rails project

def show_image(src,img_size)
img_options = { "src" => src.include?("/") ? src : "/images/#{src}" }
img_options["src"] = img_options["src"] + ".gif" unless
img_options["border"] = "0"
img_options["size"] = img_size
tag("img", img_options)

in my list.rhtml page I have the following code:

<%= show_image("WORK2R-2_02.gif","16x16") %>

But the second parameter is not working for me.

Is the problem in syntax?

plz make me clear.

A2c85dc5ee81b12e3cc0a6522e8d079d?d=identicon&s=25 Chris Hall (au5lander)
on 2007-05-02 13:47
(Received via mailing list)
you can't use the 'size' option with the tag helper, only with the
image_tag helper.  the "size" option will get translated to
height/width with image_tag

with the tag helper, you have to give all the correct attributes, so
use height/width options.

img_options["height"], img_options["width"] = img_size.split("x")
This topic is locked and can not be replied to.