views:

96

answers:

1

Hey,

I have a Rails application that lately is behaving very weird. If I start the server, I can do one successful request, but the next one ends with a failure (exactly the same request). This is not true for all pages, but for most with dynamic contents. When the failure occurs, I get this error:

Processing StartpageController#index (for 127.0.0.1 at 2010-10-05 13:54:16) [GET]
  Parameters: {"action"=>"index", "controller"=>"startpage"}
Rendering template within layouts/application
Rendering startpage/index
  Complaint Columns (1.9ms)   SHOW FIELDS FROM `complaints`

ActionView::TemplateError (You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.include?) on line #9 of app/views/complaints/_recent.html.erb:
6:   <% for complaint in @recent %>
7:     <li>
8:       <div class="span-2">
9:         <%= avatar complaint.user %>
10:       </div>
11:       <div class="span-9 last">
12:         <% bubble do %>

    app/views/complaints/_recent.html.erb:9
    app/views/complaints/_recent.html.erb:6:in `each'
    app/views/complaints/_recent.html.erb:6
    app/views/startpage/index.html.erb:9

Rendered rescues/_trace (173.4ms)
Rendered rescues/_request_and_response (24.0ms)
Rendering rescues/layout (200)
Tue Oct 05 13:54:17 +0200 2010: Read error: #<NameError: cannot remove Object::ClassMethods>
/Users/rejeep/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-2.3.9/lib/active_support/dependencies.rb:629:in `remove_const'
/Users/rejeep/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-2.3.9/lib/active_support/dependencies.rb:629:in `remove_constant'
/Users/rejeep/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-2.3.9/lib/active_support/dependencies.rb:629:in `instance_eval'
/Users/rejeep/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-2.3.9/lib/active_support/dependencies.rb:629:in `remove_constant'
/Users/rejeep/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-2.3.9/lib/active_support/dependencies.rb:476:in `remove_unloadable_constants!'
/Users/rejeep/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-2.3.9/lib/active_support/dependencies.rb:476:in `each'
/Users/rejeep/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-2.3.9/lib/active_support/dependencies.rb:476:in `remove_unloadable_constants!'
/Users/rejeep/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-2.3.9/lib/active_support/dependencies.rb:262:in `clear'
/Users/rejeep/.rvm/gems/ree-1.8.7-2010.02/gems/actionpack-2.3.9/lib/action_controller/dispatcher.rb:64:in `cleanup_application'
/Users/rejeep/.rvm/gems/ree-1.8.7-2010.02/gems/actionpack-2.3.9/lib/action_controller/reloader.rb:17:in `close'
/Users/rejeep/.rvm/gems/ree-1.8.7-2010.02/gems/rack-1.1.0/lib/rack/handler/mongrel.rb:85:in `process'
/Users/rejeep/.rvm/gems/ree-1.8.7-2010.02/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:165:in `process_client'
/Users/rejeep/.rvm/gems/ree-1.8.7-2010.02/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:164:in `each'
/Users/rejeep/.rvm/gems/ree-1.8.7-2010.02/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:164:in `process_client'
/Users/rejeep/.rvm/gems/ree-1.8.7-2010.02/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:291:in `run'
/Users/rejeep/.rvm/gems/ree-1.8.7-2010.02/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:291:in `initialize'
/Users/rejeep/.rvm/gems/ree-1.8.7-2010.02/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:291:in `new'
/Users/rejeep/.rvm/gems/ree-1.8.7-2010.02/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:291:in `run'
/Users/rejeep/.rvm/gems/ree-1.8.7-2010.02/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:274:in `initialize'
/Users/rejeep/.rvm/gems/ree-1.8.7-2010.02/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:274:in `new'
/Users/rejeep/.rvm/gems/ree-1.8.7-2010.02/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:274:in `run'
/Users/rejeep/.rvm/gems/ree-1.8.7-2010.02/gems/rack-1.1.0/lib/rack/handler/mongrel.rb:38:in `run'
/Users/rejeep/.rvm/gems/ree-1.8.7-2010.02/gems/rails-2.3.9/lib/commands/server.rb:111
/Users/rejeep/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/Users/rejeep/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
./script/server:3

The include? method is not used anywhere in my code, so I have no idea where it comes from.

I have tried with lots of different versions of Ruby, Rails, Mongrel, Passenger, Webrick, ... Currently I'm using:

  • Ruby: REE 1.8.7
  • Rails: 2.3.9
  • Mongrel: 1.2.0.pre2

EDIT: I should say that the problem only occurs in development mode.

A: 

See this post for solution: http://stackoverflow.com/questions/2256099/when-working-with-gems-in-rails-what-does-cannot-remove-objectclassmethods-s

In my case the problem occurred because I included a module with common code in lib.

rejeep