# Routes.rb error

**URL:** <https://www.ruby-forum.com/t/routes-rb-error/129086>\
**Category:** Rails\
**Created:** [February 14, 2008, 4:14am UTC](https://www.ruby-forum.com/t/routes-rb-error/129086 "2008-02-14T04:14:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 14, 2008, 4:14am UTC](https://www.ruby-forum.com/t/routes-rb-error/129086/1 "2008-02-14T04:14:37Z")

</div>

I’m new to ruby and trying to make a welcome page. I changed routes.rb  
to:  
map.connect ‘’, :controller =\> “welcome”

and deleted index.html, but still I get the error:

NameError in WelcomeController#index

uninitialized constant WelcomeController

RAILS\_ROOT: /home/hkhan/digg  
Application Trace | Framework Trace | Full Trace

/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/  
active\_support/dependencies.rb:266:in `load_missing_constant' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ active_support/dependencies.rb:453:in`const\_missing’  
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/  
active\_support/dependencies.rb:465:in `const_missing' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ active_support/inflector.rb:257:in`constantize’  
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/  
active\_support/core\_ext/string/inflections.rb:148:in `constantize' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/routing.rb:1426:in`recognize’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/  
action\_controller/dispatcher.rb:170:in `handle_request' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/dispatcher.rb:115:in`dispatch’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/  
action\_controller/dispatcher.rb:126:in `dispatch_cgi' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/dispatcher.rb:9:in`dispatch’  
/usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick\_server.rb:  
112:in `handle_dispatch' /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb: 78: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’  
/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 `each' /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’  
/usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick\_server.rb:  
62:in `dispatch' /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/servers/ webrick.rb:66 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`gem\_original\_require’  
/usr/local/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`require' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ active_support/dependencies.rb:496:in`require’  
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/  
active\_support/dependencies.rb:342:in `new_constants_in' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ active_support/dependencies.rb:496:in`require’  
/usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:  
39  
/usr/local/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`gem_original_require' /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`require’  
script/server:3

/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/  
active\_support/dependencies.rb:266:in `load_missing_constant' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ active_support/dependencies.rb:453:in`const\_missing’  
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/  
active\_support/dependencies.rb:465:in `const_missing' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ active_support/inflector.rb:257:in`constantize’  
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/  
active\_support/core\_ext/string/inflections.rb:148:in `constantize' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/routing.rb:1426:in`recognize’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/  
action\_controller/dispatcher.rb:170:in `handle_request' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/dispatcher.rb:115:in`dispatch’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/  
action\_controller/dispatcher.rb:126:in `dispatch_cgi' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/dispatcher.rb:9:in`dispatch’  
/usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick\_server.rb:  
112:in `handle_dispatch' /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb: 78: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’  
/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 `each' /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’  
/usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick\_server.rb:  
62:in `dispatch' /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/servers/ webrick.rb:66 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`gem\_original\_require’  
/usr/local/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`require' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ active_support/dependencies.rb:496:in`require’  
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/  
active\_support/dependencies.rb:342:in `new_constants_in' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ active_support/dependencies.rb:496:in`require’  
/usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:  
39  
/usr/local/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`gem_original_require' /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`require’  
script/server:3

Request

Parameters:

None

Show session dump

* * *

:csrf\_id: 4ee443b2f9f1ddb6d1ed6b0e11ffb29d  
:user\_id:  
flash: !map:ActionController::Flash::FlashHash {}

Response

Headers:

{“cookie”=\>[],  
“Cache-Control”=\>“no-cache”}

I havne’t had problems besides that. I’ve followed every step but  
can’t figure out how to fix it?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 14, 2008, 5:13am UTC](https://www.ruby-forum.com/t/routes-rb-error/129086/2 "2008-02-14T05:13:48Z")

</div>

My routes.rb looks like this:

map.connect ’ ', :controller =\> “main”, :action =\> “welcome”

Notice that following connect there are two apostrophes, not a quote.  
Also, the controller is “main” and the action is “welcome”.

Within the main controller, the following resides:

def welcome  
@categories = Category.find(:all)  
end

Look into the views folder within welcome.rhtml, and you’d find this:

\<% @categories.each do |category| %\>

\<%= link\_to "#{category.name}", :controller =\> "category", :action =\> "show", :id =\> category.id %\>

 \<% end %\>

The controller sets up the array that the view peers into and uses to  
produce the selection of links.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 15, 2008, 5:44am UTC](https://www.ruby-forum.com/t/routes-rb-error/129086/3 "2008-02-15T05:44:13Z")

</div>

Love AJAX wrote:

> Please make sure welcome\_controller.rb exists in your controllers  
> directory and then your views contain a welcome directory with an  
> rhtml file with the name of your action. In this case it would be  
> index.rhtml

That worked great…thanks

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 14, 2008, 6:51am UTC](https://www.ruby-forum.com/t/routes-rb-error/129086/4 "2008-02-14T06:51:41Z")

</div>

Please make sure welcome\_controller.rb exists in your controllers  
directory and then your views contain a welcome directory with an  
rhtml file with the name of your action. In this case it would be  
index.rhtml
