Forum: Ruby on Rails list image

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.
69339178e0e0c38cdad35aeb7622834b?d=identicon&s=25 abdulKamel (Guest)
on 2007-07-04 14:46
Hi,

i'm trying to list an image taking the url from the DB.
The code is:

<img src='<%= image.image_url %>' width="50"height="75"></img>

but it doesn't show nothing...
Can somebody help me??

thanks in advance
15eb647956921a6bc9655c3513feb139?d=identicon&s=25 lanzm (Guest)
on 2007-07-04 15:27
(Received via mailing list)
because you are in rails, why not write this:

<%= image_tag(image.image_url, :size=>"50x75") %>

and be sure the images exists. you can check this with the help of
firebug, a great plug-in for firefox...
839896e708dedbcbcb40ff9d11295d5e?d=identicon&s=25 SK (Guest)
on 2007-07-04 15:31
lanzm wrote:
> because you are in rails, why not write this:
>
> <%= image_tag(image.image_url, :size=>"50x75") %>
>
> and be sure the images exists. you can check this with the help of
> firebug, a great plug-in for firefox...

The problem is how to add what's kind of Url into database from web.
839896e708dedbcbcb40ff9d11295d5e?d=identicon&s=25 SK (Guest)
on 2007-07-04 15:33
abdulKamel wrote:
> Hi,
>
> i'm trying to list an image taking the url from the DB.
> The code is:
>
> <img src='<%= image.image_url %>' width="50"height="75"></img>
>
> but it doesn't show nothing...
> Can somebody help me??
>
> thanks in advance

I met the same problem with you.

I think the problme is the what's content of image.image_url?

Could you tell me what its content ?
69339178e0e0c38cdad35aeb7622834b?d=identicon&s=25 abdulKamel (Guest)
on 2007-07-04 15:46
>
> Could you tell me what its content ?

the content is:

/home/andrea/senior/public/images/prova.jpg

and it's the right path....
thanks
Ef3aa7f7e577ea8cd620462724ddf73b?d=identicon&s=25 Rob Biedenharn (Guest)
on 2007-07-04 16:30
(Received via mailing list)
On Jul 4, 2007, at 9:46 AM, abdulKamel wrote:
>> Could you tell me what its content ?
>
> the content is:
>
> /home/andrea/senior/public/images/prova.jpg
>
> and it's the right path....
> thanks

You only want to give '/images/prova.jpg' to the <img> or image_tag.
The value is going to be interpretted by the browser so that PATH is
not a URL.  Unless your routes are also set up to catch this and
you're finding the file and using send_file() to get it back.  (NOTE:
I'm *not* recommending this!)

It looks like you should remove RAILS_ROOT+'/public' from all of your
"url"s

-Rob

Rob Biedenharn    http://agileconsultingllc.com
Rob@AgileConsultingLLC.com
69339178e0e0c38cdad35aeb7622834b?d=identicon&s=25 abdulKamel (Guest)
on 2007-07-04 16:50
>
> It looks like you should remove RAILS_ROOT+'/public' from all of your
> "url"s
>
thanks now it works!!!!!!
This topic is locked and can not be replied to.