# Application error with unsupported format requests

**URL:** <https://www.ruby-forum.com/t/application-error-with-unsupported-format-requests/130184>\
**Category:** Rails\
**Created:** [February 26, 2008, 5:24am UTC](https://www.ruby-forum.com/t/application-error-with-unsupported-format-requests/130184 "2008-02-26T05:24:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![staypufd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@staypufd](https://www.ruby-forum.com/u/staypufd)\
**Post date:** [February 26, 2008, 5:24am UTC](https://www.ruby-forum.com/t/application-error-with-unsupported-format-requests/130184/1 "2008-02-26T05:24:53Z")

</div>

Today I got a bunch of error messages with a user probing the login page  
for api information using urls like  
/account/login.wsdl  
/account/login.aspx

To me this should be a 404 rather than an application error. However the  
route matches the standard rails routing line  
map.connect ‘:controller/:action.:format’  
and then fails in the action with a Missing Template error as I don’t  
have, and never will, a template  
login.wsdl.erb

I tried explicitly setting the template in the action with  
render :template =\> “login.html.erb” and return  
but still get the Missing Template login.wsdl.erb error.

I tried throwing this at a few high profile rails sites like 37signals  
or twitter and they don’t crash. How can you close this hole?

Cheers,  
Sam

---

<div class="post-metadata">

**Author:** ![staypufd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@staypufd](https://www.ruby-forum.com/u/staypufd)\
**Post date:** [February 26, 2008, 7:29am UTC](https://www.ruby-forum.com/t/application-error-with-unsupported-format-requests/130184/2 "2008-02-26T07:29:37Z")

</div>

On Feb 25, 2008, at 8:24 PM, Sam G. wrote:

> map.connect ‘:controller/:action.:format’
> 
> Cheers,  
> Sam

Sam–

Are you using rescue\_action\_in\_public in your ApplicationController?  
You can override Rails’ default to render a login page, return a 404,  
or whatever you prefer.

---

<div class="post-metadata">

**Author:** ![staypufd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@staypufd](https://www.ruby-forum.com/u/staypufd)\
**Post date:** [February 28, 2008, 4:16am UTC](https://www.ruby-forum.com/t/application-error-with-unsupported-format-requests/130184/3 "2008-02-28T04:16:24Z")

</div>

Steve R. wrote:

> Are you using rescue\_action\_in\_public in your ApplicationController?  
> You can override Rails’ default to render a login page, return a 404,  
> or whatever you prefer.

Bingo. For others reference the relevant parts of my app controller now  
are (without formatting)

def render\_404  
respond\_to do |format|  
format.html {render :file =\> “#{RAILS\_ROOT}/public/404.html”, :status =\>  
‘404 Not Found’}  
format.all { render :nothing =\> true, :status =\> ‘404 Not Found’}  
end  
true  
end

def rescue\_action\_in\_public(exception)  
case exception  
when ::ActionController::UnknownAction, ActiveRecord::RecordNotFound,  
::ActionController::RoutingError, ::ActionController::MissingTemplate  
then  
render\_404  
else  
render\_500  
end  
end
