Images in Agile Web Development with Rails

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 also with no luck.
How
should I code this?

Thank you,

Paul

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

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.

Yeah, regular expressions can be pretty foggy. :slight_smile:

Glad I could help,
David

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

Paul