# Rails urls & the AWD book

**URL:** <https://www.ruby-forum.com/t/rails-urls-the-awd-book/70646>\
**Category:** Rails\
**Created:** [February 20, 2006, 12:00am UTC](https://www.ruby-forum.com/t/rails-urls-the-awd-book/70646 "2006-02-20T00:00:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wpwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d6d6ee/32.png) [@wpwood](https://www.ruby-forum.com/u/wpwood)\
**Post date:** [February 20, 2006, 12:00am UTC](https://www.ruby-forum.com/t/rails-urls-the-awd-book/70646/1 "2006-02-20T00:00:22Z")

</div>

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](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](http://localhost:3000/admin/images/file.png) when I look at it from the  
admin\_controller or [http://localhost:3000/store/images/file.png](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

---

<div class="post-metadata">

**Author:** ![wpwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d6d6ee/32.png) [@wpwood](https://www.ruby-forum.com/u/wpwood)\
**Post date:** [February 20, 2006, 12:27am UTC](https://www.ruby-forum.com/t/rails-urls-the-awd-book/70646/2 "2006-02-20T00:27:15Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![wpwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d6d6ee/32.png) [@wpwood](https://www.ruby-forum.com/u/wpwood)\
**Post date:** [February 20, 2006, 2:50am UTC](https://www.ruby-forum.com/t/rails-urls-the-awd-book/70646/3 "2006-02-20T02:50:07Z")

</div>

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

Best regards,  
Bill  
----- Original Message -----  
From: “Stefan Liden” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Sunday, February 19, 2006 5:27 PM  
Subject: [Rails] Re: Rails urls & the AWD book
