Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #6863 (closed defect: invalid)

Opened 3 years ago

Last modified 2 years ago

Name clash between ActionController and ActionWebService::Dispatcher::ActionController

Reported by: alexey Assigned to: core
Priority: normal Milestone: 1.x
Component: ActiveRecord Version: 1.1.6
Severity: minor Keywords:
Cc:

Description

I want errors on AJAX request to be plain text. Therefore, I put the following code in app/controllers/application.rb:

  def rescue_action(exception)
    return super unless request.xml_http_request?

    case exception
    when ActionController::RoutingError, ActionController::UnknownAction 
      render :text => 'Not found', :status => 404
    else 
      render :text => "#{exception.class}: #{exception.message}"
    end
  end

It fails with "NameError: uninitialized constant RoutingError". Reason: in the scope where this code is executed, ActionController surprisingly resolves to ActionWebService::Dispatcher::ActionController, which doesn't have RoutingError defined, of course.

Adding "config.frameworks -= [ :action_web_service ]" to config/environment.rb works around the issue, but this only works for me because I don't need ActionWebServices in my app.

Change History

01/13/07 21:05:19 changed by dcmanges

  • status changed from new to closed.
  • resolution set to invalid.

You should be able to do:

when ::ActionController::RoutingError, ::ActionController::UnknownAction 

and if all else fails...

Object.const_get('ActionController')