# Images in Agile Web Development with Rails

**URL:** <https://www.ruby-forum.com/t/images-in-agile-web-development-with-rails/51287>\
**Category:** Rails\
**Created:** [December 29, 2005, 3:22am UTC](https://www.ruby-forum.com/t/images-in-agile-web-development-with-rails/51287 "2005-12-29T03:22:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ptremblett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/dc4da7/32.png) [@ptremblett](https://www.ruby-forum.com/u/ptremblett)\
**Post date:** [December 29, 2005, 3:22am UTC](https://www.ruby-forum.com/t/images-in-agile-web-development-with-rails/51287/1 "2005-12-29T03:22:58Z")

</div>

Hi,

I am working through Agile Web D. with Rails and I am at pg 69  
second last paragraph says “put some images in the public/images  
directory…” how do you code the link that is stored in the data  
base I  
have tried http:public/images/name .jpg with no avail I have tried the  
fully  
qualified address [http://home/../../../../name.jpg](http://home/../../../../name.jpg) also with no luck.  
How  
should I code this?

Thank you,

Paul

---

<div class="post-metadata">

**Author:** ![ptremblett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/dc4da7/32.png) [@ptremblett](https://www.ruby-forum.com/u/ptremblett)\
**Post date:** [December 29, 2005, 3:38am UTC](https://www.ruby-forum.com/t/images-in-agile-web-development-with-rails/51287/2 "2005-12-29T03:38:03Z")

</div>

The url would be images/filename.jpg, not public/images/filename.jpg. I  
think that might be your problem.

Also, you might want to take a look at the file\_column plugin. Details  
are on the plugins page on the rails wiki.

Craig

---

<div class="post-metadata">

**Author:** ![ptremblett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/dc4da7/32.png) [@ptremblett](https://www.ruby-forum.com/u/ptremblett)\
**Post date:** [December 29, 2005, 3:38am UTC](https://www.ruby-forum.com/t/images-in-agile-web-development-with-rails/51287/3 "2005-12-29T03:38:04Z")

</div>

In the ‘New’ and ‘Editing Product’ screens, fill in the ‘Image url:’  
text field with ‘/images/your\_image\_name.jpg’. Then change the  
regular expression in the ‘validates\_format\_of :image\_url :with…’  
directive (in app/models/product.rb) to be %r{.(gif|jpg|png)$}i  
(leaving off the ^http:.+ stuff).

I’ve published some of the gory details behind this change at http://  
[www.ruppconsulting.com/?p=7](http://www.ruppconsulting.com/?p=7).

---

<div class="post-metadata">

**Author:** ![ptremblett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/dc4da7/32.png) [@ptremblett](https://www.ruby-forum.com/u/ptremblett)\
**Post date:** [December 29, 2005, 4:26am UTC](https://www.ruby-forum.com/t/images-in-agile-web-development-with-rails/51287/4 "2005-12-29T04:26:10Z")

</div>

Yeah, regular expressions can be pretty foggy. 🙂

Glad I could help,  
David

---

<div class="post-metadata">

**Author:** ![ptremblett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/dc4da7/32.png) [@ptremblett](https://www.ruby-forum.com/u/ptremblett)\
**Post date:** [December 29, 2005, 3:53am UTC](https://www.ruby-forum.com/t/images-in-agile-web-development-with-rails/51287/5 "2005-12-29T03:53:05Z")

</div>

Thanks David, it works now and thanks also for the article on regular  
expressions. That has cleared a lot of fog!

Paul
