# Unknown Action doesn't raise exception?

**URL:** <https://www.ruby-forum.com/t/unknown-action-doesnt-raise-exception/114148>\
**Category:** Rails\
**Created:** [September 8, 2007, 4:50pm UTC](https://www.ruby-forum.com/t/unknown-action-doesnt-raise-exception/114148 "2007-09-08T16:50:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [September 8, 2007, 4:50pm UTC](https://www.ruby-forum.com/t/unknown-action-doesnt-raise-exception/114148/1 "2007-09-08T16:50:39Z")

</div>

As I am in development environment, I wrote in my config/environment.rb  
ActionController::Base.consider\_all\_requests\_local = false

in my application.rb, I wrote  
def rescue\_action\_in\_public(exception)  
case exception  
when RoutingError, UnknownAction  
render :file =\> “#{RAILS\_ROOT}/public/404.html”, :status =\>  
404  
else  
logger.error "Error raised: " + exception.to\_s  
render :file =\> “#{RAILS\_ROOT}/public/500.html”, :status =\>  
500  
end  
end

## trying to call an url at : [http://0.0.0.0:3000/cities/new](http://0.0.0.0:3000/cities/new) (there is no new action in the controller) I got a blank page with the following message :

## Unknown action No action responded to new

how can I get my rescue\_action\_in\_public(exception) called ?

thanks

kad

---

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [September 8, 2007, 6:14pm UTC](https://www.ruby-forum.com/t/unknown-action-doesnt-raise-exception/114148/2 "2007-09-08T18:14:17Z")

</div>

Kad K. wrote:

> As I am in development environment, I wrote in my config/environment.rb  
> ActionController::Base.consider\_all\_requests\_local = false
> 
> in my application.rb, I wrote  
> def rescue\_action\_in\_public(exception)  
> case exception  
> when RoutingError, UnknownAction  
> render :file =\> “#{RAILS\_ROOT}/public/404.html”, :status =\>  
> 404  
> else  
> logger.error "Error raised: " + exception.to\_s  
> render :file =\> “#{RAILS\_ROOT}/public/500.html”, :status =\>  
> 500  
> end  
> end
> 
> ## trying to call an url at : [http://0.0.0.0:3000/cities/new](http://0.0.0.0:3000/cities/new) (there is no new action in the controller) I got a blank page with the following message :
> 
> ## Unknown action No action responded to new
> 
> how can I get my rescue\_action\_in\_public(exception) called ?
> 
> thanks
> 
> kad

for interested people I answer myself ;-))

using rescue\_action\_locally (exception) did it…

then trapping the exception

```
def rescue_action_locally(exception)
 case exception
 when ::ActionController::UnknownAction

```

…
