Controllers in modules, not recognised - driving me mad!

Hi, I hope somebody can help me here but I’m having a very strange
problem getting Rails to recognise controllers inside modules. The
strange thing is, it was working the other day and I’ve not changed
anything as far as I’m aware. I’m running on OSX using Ruby 1.8.4 and
Rails RC1 (but I’ve also tried rolling back to Rails 1.0 and tried Edge
Rails) and the problem occurs using lighty, webrick and when I run my
functional tests (I have a few assert_routings).

I have a Dashboard controller in an admin module. I have the following
file:

app/controllers/admin/dashboard_controller.rb

class Admin::DashboardController < ActionController::Base
def index
# do stuff
end
end

Now, this should be automatically picked up by Rails as
http://myapp/admin/dashboard and http://myapp/admin/dashboard/index -
but they aren’t, I get routing errors.

I also have the following test:

require File.dirname(FILE) + ‘/…/test_helper’

class RoutingTest < Test::Unit::TestCase
def setup
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end

def test_admin_routing
assert_routing ‘/admin’, :controller => ‘admin/dashboard’, :action
=> ‘index’
assert_routing ‘/admin/dashboard’, :controller =>
‘admin/dashboard’, :action => ‘index’
end
end

These tests fail.

What could be happening here? There isn’t anything revealing in my logs,
and like I said this was working the other day - they only work I’ve
been doing on my app since then is on one of my model classes and its
unit tests - I’ve not been touching my views/controllers.

Here’s the relevant exerpt from my logs:

Processing Base#index (for 127.0.0.1 at 2006-03-27 00:34:05) [GET]
Session ID: 6145b5c6d7884639db0adc70113f5e86
Parameters: {}

ActionController::RoutingError (Recognition failed for
“/admin/dashboard/”):
.//vendor/rails/actionpack/lib/action_controller/routing.rb:488:in
recognition_failed' .//vendor/rails/actionpack/lib/action_controller/routing.rb:478:in recognize!’
.//vendor/rails/railties/lib/dispatcher.rb:38:in dispatch' .//vendor/rails/railties/lib/webrick_server.rb:115:in handle_dispatch’
.//vendor/rails/railties/lib/webrick_server.rb:81:in service' /usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in service’
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in run' /usr/local/lib/ruby/1.8/webrick/server.rb:173:in start_thread’
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in start_thread' /usr/local/lib/ruby/1.8/webrick/server.rb:95:in start’
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in start' /usr/local/lib/ruby/1.8/webrick/server.rb:23:in start’
/usr/local/lib/ruby/1.8/webrick/server.rb:82:in start' .//vendor/rails/railties/lib/webrick_server.rb:67:in dispatch’
.//vendor/rails/railties/lib/commands/servers/webrick.rb:59
.//vendor/rails/activesupport/lib/active_support/dependencies.rb:149:in
`require’
.//vendor/rails/railties/lib/commands/server.rb:30
script/server:3

Rendering
./script/…/config/…/vendor/rails/actionpack/lib/action_controller/templates/rescues/layout.rhtml
(404 Page Not Found)

OK I finally worked this out after much hairpulling! The aforementioned
model I had been working on was called Admin and this was conflicting
with the ‘admin’ module.

Thank you for this! I’ve also been pulling my hair, but no more! Thanks!