Rails urls & the AWD book

Greetings!

I’m having a hard time understanding the way Rails handles urls. I’m
specifically having real trouble with the image_urls in the Depot app in
the Agile Web D. book.

If I enter “\image\file.png” in the Add Product page, the image is
displayed in the other views and Properties shows
http://localhost:3000/images/file.png
If I leave off the leading backslash and enter “image\file.png” the
image does not display and Properties shows
http://localhost:3000/admin/images/file.png when I look at it from the
admin_controller or http://localhost:3000/store/images/file.png when I
look at it from the store_controller.

In either case, the validation the book shows for image_url really trips
me up because it’s checking to see that the string begins with “http:”.
What’s up with that?

Also, when I’m supplying the location in the unit test I’m having to use
a string I really don’t understand. The string is:
“c:\instantrails\rails_apps\depot\public\images\rails.png”
Why do some of the '' characters have to be escaped and others not? Or
is that not what’s going on?

Could someone help? At least point me to some docs on this topic?

Thanks,
Bill

Bill W. wrote:

In either case, the validation the book shows for image_url really trips
me up because it’s checking to see that the string begins with “http:”.
What’s up with that?

This was a mistake the made and they have updated the PDF that now have
the following validation code:

validates_format_of :image_url,
:with => %r{.(gif|jpg|png)$}i,
:message => “must be a URL for a GIF, JPG, or PNG image”

Here is an entry in the errata at the Pragmatic website:
"At bottom of page 69 yous suggest to add some image … well it’s nice
BUT …
since at botom of page 66 page you make us write a validates rule where
image_url must begin with http: i don’t realy know what to append in the
input field image_url to point out the right image … is that
http://localhost:3000/public/images/toto.png or whatever ?
you should there help us in the deep with an example i suggest …
(sorry but i’m not a good english speaker … d�ja en francais j’ai du
mal alors …)
(not good english speaker … sorry)

(Dave says: I’ve finally given in on this and removed the check for the
leading http)–ovnk"

Hope this helps a bit
/Stefan

Thanks for clearing up that part of my confusion, Stefan. I appreciate
it.

Best regards,
Bill
----- Original Message -----
From: “Stefan Liden” [email protected]
To: [email protected]
Sent: Sunday, February 19, 2006 5:27 PM
Subject: [Rails] Re: Rails urls & the AWD book