Forum: Ruby on Rails Controllers in modules, not recognised - driving me mad!

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Luke R. (Guest)
on 2006-03-27 03:34
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

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

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    =
    @response   =

  def test_admin_routing
     assert_routing '/admin', :controller => 'admin/dashboard', :action
=> 'index'
     assert_routing '/admin/dashboard', :controller =>
'admin/dashboard', :action => 'index'

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 at 2006-03-27 00:34:05) [GET]
  Session ID: 6145b5c6d7884639db0adc70113f5e86
  Parameters: {}

ActionController::RoutingError (Recognition failed for
    .//vendor/rails/railties/lib/dispatcher.rb:38:in `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'

(404 Page Not Found)
Luke R. (Guest)
on 2006-03-27 04:55
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.
Carl-Johan K. (Guest)
on 2006-03-28 02:42
(Received via mailing list)
Thank you for this! I've also been pulling my hair, but no more! Thanks!
This topic is locked and can not be replied to.