# Controller named /2010

**URL:** <https://www.ruby-forum.com/t/controller-named-2010/180862>\
**Category:** Rails\
**Created:** [December 30, 2009, 6:33pm UTC](https://www.ruby-forum.com/t/controller-named-2010/180862 "2009-12-30T18:33:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![theduz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/90ced4/32.png) [@theduz](https://www.ruby-forum.com/u/theduz)\
**Post date:** [December 30, 2009, 6:33pm UTC](https://www.ruby-forum.com/t/controller-named-2010/180862/1 "2009-12-30T18:33:48Z")

</div>

Hi,

I’ve been asked to create a controller called 2010 on rails 2.3.2 but  
script/generate controller 2010 fails with

wrong constant name 2010Helper

I tried creating everything manually, but still receive a ‘wrong  
constant name’ error.

NameError in 2010Controller#index

wrong constant name 2010Controller

So, is there any way to fix this up to get it to work?

Thank you.

Regards,  
Rich

Here is a partial stack trace, btw.  
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/  
active\_support/inflector.rb:285:in `const_defined?' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/ active_support/inflector.rb:285:in `constantize’  
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/  
active\_support/inflector.rb:284:in `each' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/ active_support/inflector.rb:284:in `constantize’  
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/  
active\_support/core\_ext/string/inflections.rb:143:in `constantize' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/ action_controller/routing/route_set.rb:386:in `recognize’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/  
action\_controller/dispatcher.rb:148:in `handle_request' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/ action_controller/dispatcher.rb:107:in `dispatch’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/  
action\_controller/dispatcher.rb:104:in `synchronize' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/ action_controller/dispatcher.rb:104:in `dispatch’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/  
action\_controller/dispatcher.rb:120:in `dispatch_cgi' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/ action_controller/dispatcher.rb:35:in `dispatch’

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

---

<div class="post-metadata">

**Author:** ![theduz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/90ced4/32.png) [@theduz](https://www.ruby-forum.com/u/theduz)\
**Post date:** [December 30, 2009, 6:36pm UTC](https://www.ruby-forum.com/t/controller-named-2010/180862/2 "2009-12-30T18:36:44Z")

</div>

Ruby won’t let you make a class called 2010Controller, as it is not a  
valid class name.

Why are you being told to create a controller of a specific name? Is  
it for path reasons? If so, call it something else (./script/generate  
controller twenty\_ten) and then use a route to set things up from  
/2010/ to what you just made.

–Michael

On Wed, Dec 30, 2009 at 11:32, theduz [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> NameError in 2010Controller#index
> 
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/  
> action\_controller/dispatcher.rb:104:in `dispatch’  
> For more options, visit this group at [http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

–  
(Ruby, Rails, Random) blog: [http://skandragon.blogspot.com/](http://skandragon.blogspot.com/)

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

---

<div class="post-metadata">

**Author:** ![theduz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/90ced4/32.png) [@theduz](https://www.ruby-forum.com/u/theduz)\
**Post date:** [December 30, 2009, 6:44pm UTC](https://www.ruby-forum.com/t/controller-named-2010/180862/3 "2009-12-30T18:44:56Z")

</div>

On Dec 30, 11:35 am, Michael G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

Somebody wants the url to be [http://example.com/2010/index.html](http://example.com/2010/index.html). They  
didn’t say why, they just want it. I originally proposed a redirect  
in the web server, but they think they want /2010 in the address bar.

I wondered if a route might be something to investigate, but I’m not  
100% clear on how to reroute requests from /2010 to /twenty\_ten. Will  
a special route take care that link\_to :controller =\>  
‘twenty\_ten’, :action =\> ‘foo’ generates an html link like  
[http://example.com/2010/foo](http://example.com/2010/foo) ?

Thank you.

Regards,  
Rich

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

---

<div class="post-metadata">

**Author:** ![theduz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/90ced4/32.png) [@theduz](https://www.ruby-forum.com/u/theduz)\
**Post date:** [December 30, 2009, 6:47pm UTC](https://www.ruby-forum.com/t/controller-named-2010/180862/4 "2009-12-30T18:47:52Z")

</div>

map.connect ‘2010/:action’, :controller =\> ‘twenty\_ten’

If using resources, I think this will work:

map.resource ‘2010’, :controller =\> ‘twenty\_ten’

None of those are tested, but should be close I hope.

–Michael

On Wed, Dec 30, 2009 at 11:43, theduz [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 
> 
> a special route take care that link\_to :controller =\>  
> You received this message because you are subscribed to the Google G. “Ruby on Rails: Talk” group.  
> To post to this group, send email to removed\_email\_address@domain.invalid.  
> To unsubscribe from this group, send email to removed\_email\_address@domain.invalid.  
> For more options, visit this group at [http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

–  
(Ruby, Rails, Random) blog: [http://skandragon.blogspot.com/](http://skandragon.blogspot.com/)

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

---

<div class="post-metadata">

**Author:** ![theduz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/90ced4/32.png) [@theduz](https://www.ruby-forum.com/u/theduz)\
**Post date:** [December 30, 2009, 7:21pm UTC](https://www.ruby-forum.com/t/controller-named-2010/180862/5 "2009-12-30T19:21:13Z")

</div>

try a controller named twenty\_ten, and:  
map.resources :twenty\_ten, :as =\> “2010”

On Wed, Dec 30, 2009 at 12:43 PM, theduz [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 
> 
> a special route take care that link\_to :controller =\>  
> You received this message because you are subscribed to the Google G.  
> “Ruby on Rails: Talk” group.  
> To post to this group, send email to removed\_email\_address@domain.invalid.  
> To unsubscribe from this group, send email to  
> removed\_email\_address@domain.invalid[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> .  
> For more options, visit this group at  
> [http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

–  
// anything worth taking seriously is worth making fun of  
// [http://blog.devcaffeine.com/](http://blog.devcaffeine.com/)

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

---

<div class="post-metadata">

**Author:** ![theduz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/90ced4/32.png) [@theduz](https://www.ruby-forum.com/u/theduz)\
**Post date:** [December 30, 2009, 6:51pm UTC](https://www.ruby-forum.com/t/controller-named-2010/180862/6 "2009-12-30T18:51:22Z")

</div>

Now that I read your words a bit more closely, I think you are  
confused about what a route is and what a controller is.

By convention, this configuration:

map.resource :foo

means “things like /foo/action will go to controller foo” but that is  
not required. It is merely convention. Like many things in Rails,  
you can change things, but it requires configuration to do it. In  
this case,

map.resource ‘2010’, :controller =\> ‘foo’

should be close. It says “I don’t care what you think you want when  
you see /2010, but I want it handled by the controller ‘foo’ instead.”  
Note that this does not mean that /foo exists, although if you leave  
your default routes in it will. However, the more specific should  
take priority and you should be good to go.

–Michael

On Wed, Dec 30, 2009 at 11:43, theduz [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 
> 
> a special route take care that link\_to :controller =\>  
> You received this message because you are subscribed to the Google G. “Ruby on Rails: Talk” group.  
> To post to this group, send email to removed\_email\_address@domain.invalid.  
> To unsubscribe from this group, send email to removed\_email\_address@domain.invalid.  
> For more options, visit this group at [http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

–  
(Ruby, Rails, Random) blog: [http://skandragon.blogspot.com/](http://skandragon.blogspot.com/)

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).
