Unknown Action doesn't raise exception?

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 (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

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 (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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs