views:

237

answers:

1

If I try the Root-URL of my Rails-App, I get the following error:

NoMethodError undefined method `[]' for :company_url:Symbol

# (part of the) content of my config/routes.rb
ActionController::Routing::Routes.draw do |map|
  map.company 'company', :controller => 'companies', :action => 'index'
  map.root :company_url
end

But the API-Doc for ActionController::Routing says explicitly:

You can also specify an already-defined named route in your map.root call:

# In routes.rb
map.new_session :controller => 'sessions', :action => 'new'
map.root :new_session

What am I doing wrong? :-)

+1  A: 

You're not mapping your named route (company) to your root, you ARE mapping and undefined route (company_url).

I think what you're confusing is the autogenerated URLs created by map.resources :company which would generate a set of *_url routes automagically. You're using map.company, a named route -- not map.resources.

John Paul Ashenfelter
Shouldn't that *_url route be there "automagically" if I see the following line after submitting 'rake routes':company /company {:controller=>"companies", :action=>"index"}?
Javier
Otto