andrew taylor
2006-Aug-04 03:30 UTC
[Rails] 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 :) 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:in `eval'' from c:/_/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/routing.rb:535:in `write_recognition'' from c:/_/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/routing.rb:630:in `draw'' from ./script/../config/../config/routes.rb:1 from c:/_/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:140:in `load'' from c:/_/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/routing.rb:607:in `reload'' from c:/_/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/initializer.rb:239:in `initialize_routing'' from c:/_/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/initializer.rb:105:in `process'' ... 7 levels... from c:/_/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/commands/server.rb:30 from c:/_/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' from c:/_/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' from script/server:3 /c/_/workspace/puffin_server/puffin -- Posted via http://www.ruby-forum.com/.
Trevor Squires
2006-Aug-05 18:35 UTC
[Rails] route error with controllers in a module, should just work
On 3-Aug-06, at 8:30 PM, andrew taylor wrote:> 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 :) > > But now webrick won''t even start ??? Look at those 4 colons ::::, > what > is that about ? >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'' HTH Trevor -- Trevor Squires http://somethinglearned.com> 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:in `eval'' > from > c:/_/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/ > action_controller/routing.rb:535:in > `write_recognition'' > from > c:/_/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/ > action_controller/routing.rb:630:in > `draw'' > from ./script/../config/../config/routes.rb:1 > from > c:/_/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/ > lib/active_support/dependencies.rb:140:in > `load'' > from > c:/_/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/ > action_controller/routing.rb:607:in > `reload'' > from > c:/_/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/ > initializer.rb:239:in > `initialize_routing'' > from > c:/_/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/ > initializer.rb:105:in > `process'' > ... 7 levels... > from > c:/_/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/ > commands/server.rb:30 > from > c:/_/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/ > custom_require.rb:21:in > `require'' > from > c:/_/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/ > lib/active_support/dependencies.rb:147:in > `require'' > from script/server:3 > /c/_/workspace/puffin_server/puffin > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails