rails/rails — Issue #3736: Super Weird Class loading issue with Rails 3.0.11
Author: jtushman
Created: 2011-11-23 15:54:27+00:00
State: open

Hi guys,

I am stuck on, what i think is a class loader issue.

In my app/models directory i have the following files:

reductions/base.rb
reductions/conversions_by_bucket.rb
reductions/conversions_by_hour.rb
reductions/impressions_by_hour.rb

I've simplified these class so they only contain:

def self.hello
"hello"
end

And checkout this weirdness from the rails console:

> Reductions::ImpressionsByHour.hello
=> "hello"
> Reductions::ConversionsByHour.hello
=> "hello"
> Reductions::ImpressionsByBucket.hello

=> NoMethodError: undefined method `hello' for
Reductions::ImpressionsByBucket:Class

BUT ...

> require 'reductions/conversions_by_bucket.rb'
=> nil
> Reductions::ConversionsByBucket.hello
=> "hello"

Soooooo weird!!! So why is reductions/conversions_by_bucket.rb not
being loaded by the class loader?!

The issue seems to happen only with the intersection of two Gems in my Gemfile. If you remove either one it works, but both together cause the issue

Rails project issolating the issue: https://github.com/jtushman/classloadingissue

Thread on the issue: http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/8b595c981f106e83