# Else case in respond\_to

**URL:** <https://www.ruby-forum.com/t/else-case-in-respond-to/85070>\
**Category:** Rails\
**Created:** [February 9, 2007, 8:33pm UTC](https://www.ruby-forum.com/t/else-case-in-respond-to/85070 "2007-02-09T20:33:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jshow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/977dab/32.png) [@jshow](https://www.ruby-forum.com/u/jshow)\
**Post date:** [February 9, 2007, 8:33pm UTC](https://www.ruby-forum.com/t/else-case-in-respond-to/85070/1 "2007-02-09T20:33:22Z")

</div>

Has anybody found out how to deal with unknown respond\_to’s?

for example:

```
 respond_to do |format|
   format.html # show.rhtml
   format.xml { head :status => :method_not_allowed }
   format.rss { head :status => :method_not_allowed }
   format.atom { head :status => :method_not_allowed }

```

will deal well with predetermined types (html, xml, rss, atom)

but I’d like to respond appropriately to say ‘format.jpg’.

any thoughts?

Cheers,  
Jodi  
General Partner  
The nNovation Group inc.  
www.nnovation.ca/blog

---

<div class="post-metadata">

**Author:** ![jshow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/977dab/32.png) [@jshow](https://www.ruby-forum.com/u/jshow)\
**Post date:** [February 9, 2007, 9:03pm UTC](https://www.ruby-forum.com/t/else-case-in-respond-to/85070/2 "2007-02-09T21:03:24Z")

</div>

On 2/9/07, Jodi S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> will deal well with predetermined types (html, xml, rss, atom)
> 
> but I’d like to respond appropriately to say ‘format.jpg’.
> 
> any thoughts?

Create your own mime types. Topfunky shows you how –  
[http://nubyonrails.com/articles/2006/12/18/dynamic-graphics-with-rails-1-2](http://nubyonrails.com/articles/2006/12/18/dynamic-graphics-with-rails-1-2)

–  
Rick O.  
[http://weblog.techno-weenie.net](http://weblog.techno-weenie.net)  
[http://mephistoblog.com](http://mephistoblog.com)

---

<div class="post-metadata">

**Author:** ![jshow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/977dab/32.png) [@jshow](https://www.ruby-forum.com/u/jshow)\
**Post date:** [February 9, 2007, 9:08pm UTC](https://www.ruby-forum.com/t/else-case-in-respond-to/85070/3 "2007-02-09T21:08:26Z")

</div>

On 9-Feb-07, at 3:02 PM, Rick O. wrote:

> > ```
> > format.rss { head :status => :method_not_allowed }
> > 
> > ```
> 
> rails-1-2  
> Thanx Rick - but I’m trying to handled edge cases - mime types asked  
> for, but application doesn’ t handle. intentionally.

make sense?

J
