rc3.org

Strong opinions weakly held

rc3.org header image 1

Resolving the NameError problem with Rails 1.2

February 5th, 2007 · 9 Comments

I’m just posting this because I have been fiddling around with a Rails 1.2 application for days in utter frustration due to an obscure problem. Every time I tried to load a page, I got an error message like this:

Mon Feb 05 11:22:35 -0500 2007: Error calling Dispatcher.dispatch #<NameError: cannot remove Object::COPYRIGHT>

The name of the object that couldn’t be removed has varied. The NameError has also caused a number of other problems that basically left my application dead. Today some searching revealed the problem. In Rails 1.2, you must put include statements inside class definitions. I had the line:

include REXML

outside a class definition and it blew up my whole application. Fun.

This blog post is provided as a service to the next person who runs into this problem.

9 responses so far ↓

  • 1 Chris // Feb 8, 2007 at 8:29 am

    Wow! This tip was exactly what I needed. Tracking this down would have been very time consuming. Thanks for the tip.

  • 2 Damon // Mar 8, 2007 at 4:44 pm

    Thank you! I just nearly blew a gasket trying to figure this out. Moving the includes inside the class cured it for me.

  • 3 Ajay // Mar 10, 2007 at 12:20 am

    Your tip worked for me as well. The strange thing was that although your tip fixed my problem, I hadn’t changed any of the require statements in my code in the last few days, yet the problem appeared only today. I was about to go back a few revisions to ferret out the change responsible for the problems, when I decided to do a google search instead….

    Thanks a million.

  • 4 george // Apr 19, 2007 at 2:52 am

    i love you i love you!!! thanks. 2 days going crazy. saved by a 10 line blog entry.

  • 5 chris // Jun 13, 2007 at 5:38 pm

    This definitely helped me track down the bizarre issue I was having. Thanks!

  • 6 cc // Jun 13, 2007 at 8:24 pm

    Two hours of debugging, and this fixes it in two seconds. I’m thrilled, yet slightly angered :-p

  • 7 Bob // Jul 26, 2007 at 4:34 pm

    Worked like a charm. Thanks!

  • 8 Rupert Meese // May 5, 2008 at 5:56 am

    Thanks, that saved my a whole load of time and trouble.

  • 9 sd.codewarrior // May 19, 2008 at 10:23 am

    Thanks! This error occurred intermittently in my case which made it particularly ugly. I spent several hours before finding your post.

Leave a Comment

You can comment using OpenID:

Or you can just enter your personal information and comment that way. Your email address is required but won't be displayed.

Please enter your comment. Markdown is supported.