Route error with controllers in a module, should just work

This is ALL I have added to my routes.rb

map.connect ‘admin’, :controller => ‘/admin/welcome’

I have found plenty of examples saying this is correct if you have a
WelcomeController in the Admin module, which I do :slight_smile:

But now webrick won’t even start ??? Look at those 4 colons ::::, what
is that about ?

help !

=> Booting WEBrick…
generated/routing/recognition.rb:38:in write_recognition': compile error (SyntaxError) generated/routing/recognition.rb:35: parse error, unexpected tCOLON3, expecting tCONSTANT return {"controller" => ::::Admin::WelcomeController, "action" => "index"} ^ generated/routing/recognition.rb:35: dynamic constant assignment return {"controller" => ::::Admin::WelcomeController, "action" => "index"} ^ generated/routing/recognition.rb:35: parse error, unexpected tASSOC, expecting tCOLON2 or '[' or '.' return {"controller" => ::::Admin::WelcomeController, "action" => "index"} ^ generated/routing/recognition.rb:35: parse error, unexpected '}', expecting kEND from c:/_/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12 .3/lib/action_controller/routing.rb:630:ineval’
write_recognition' from c:/_/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/routing.rb:630:indraw’
from ./script/…/config/…/config/routes.rb:1
load' from c:/_/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/routing.rb:607:inreload’
initialize_routing' from c:/_/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/initializer.rb:105:inprocess’
… 7 levels…
require' from c:/_/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:inrequire’
from script/server:3

On 3-Aug-06, at 8:30 PM, andrew taylor wrote:

Hi Andrew,

I wish I could give you an adequate explanation of what’s happening
but for some reason my brain isn’t in gear today and (to be honest) I
can’t be bothered sifting through rails’ code to make sure I’m talk
talking rubbish.

So instead, I’ll just give you the quick version and solution.

map.connect ‘anchors’ the class name generated from the :controller
=> ‘/admin/welcome’ to the toplevel namespace by (apparently)
always putting ‘::’ in front of the generated class name.
Unfortunately, you’re also trying to anchor the class name to the
toplevel namespace by putting in that leading slash ‘/’ character.
Which is always converted to ‘::’.

Do this:

map.connect ‘admin’, :controller => ‘admin/welcome’


Trevor S.

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