# Dealing with empty 404 images

**URL:** <https://www.ruby-forum.com/t/dealing-with-empty-404-images/80150>\
**Category:** Rails\
**Created:** [March 12, 2006, 11:58pm UTC](https://www.ruby-forum.com/t/dealing-with-empty-404-images/80150 "2006-03-12T23:58:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_Cox](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@James\_Cox](https://www.ruby-forum.com/u/James_Cox)\
**Post date:** [March 12, 2006, 11:58pm UTC](https://www.ruby-forum.com/t/dealing-with-empty-404-images/80150/1 "2006-03-12T23:58:35Z")

</div>

so i’d like to do the following

map.connect ‘some/path’, :controller =\> ‘Foo’ if server.status == ‘404’

in other words:

if i get a 404 response, and a given path, i’d like to handle it by  
returning my own content.

no- i don’t want a generic all-404 error page, i want to be able to  
handle individual 404s. Where is this useful? For an address book  
application where i don’t have photos of all the users, or similar.

anyone able to help?

---

<div class="post-metadata">

**Author:** ![James\_Cox](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@James\_Cox](https://www.ruby-forum.com/u/James_Cox)\
**Post date:** [March 13, 2006, 12:45am UTC](https://www.ruby-forum.com/t/dealing-with-empty-404-images/80150/2 "2006-03-13T00:45:34Z")

</div>

On Sunday 12 Mar 2006 22:58, James Cox wrote:

> if i get a 404 response, and a given path, i’d like to handle it by  
> returning my own content.

I’m sure that’s possible, however…

> no- i don’t want a generic all-404 error page, i want to be able to  
> handle individual 404s. Where is this useful? For an address book  
> application where i don’t have photos of all the users, or similar.

I had a similar thing, but solved it in my views instead, rather like:

\<% unless @person.image.nil? || @person.image.empty? -%\>  
\<%= image\_tag @person.image %\>  
\<% else -%\>  
\<%= image\_tag “no\_pic” %\>  
\<% end -%\>

Cheers,

~Dave

–

Dave S.  
Rent-A-Monkey Website Development

> **[Tree Removal Service For Home & Businesses in Salt Lake City, UT](https://www.rentamonkey.com/)**
>
> Rent A Monkey Tree Service provides the safest, highest-quality tree removal for Salt Lake City, UT homes and businesses. Request a service today!

PGP Key: [http://www.rentamonkey.com/pgpkey.asc](http://www.rentamonkey.com/pgpkey.asc)

---

<div class="post-metadata">

**Author:** ![James\_Cox](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@James\_Cox](https://www.ruby-forum.com/u/James_Cox)\
**Post date:** [March 13, 2006, 12:50am UTC](https://www.ruby-forum.com/t/dealing-with-empty-404-images/80150/3 "2006-03-13T00:50:21Z")

</div>

Dave S. wrote:

> \<% unless @person.image.nil? || @person.image.empty? -%\>  
> \<%= image\_tag @person.image %\>  
> \<% else -%\>  
> \<%= image\_tag “no\_pic” %\>  
> \<% end -%\>

Alas I base mine on id’s of listing rather than a field - but thanks. I  
hope i can hack rails or lighty into submission over this one.
