Hi All
I have been struggling with this issue for a long time now. And before I began to describe the problem its important to know that this problem happens only in Development environment.
I am using Rails 2.0.2, here are my associations
class User has_many :comments has_one :profile, :as => :profileable delegate :email, :to => :profile
end
First call to comment.user.email works just fine the associated profile object gets loaded and the delegation occurs just fine.
However, a second/subsequent call to comment.user.email throws ActiveRecord::ConfigurationError: Association named 'profile' was not found; perhaps you misspelled it?
The solution I have tried are and none have worked are
1). put a require_dependency 'models/profile' in environment.rb 2). put a require 'models/profile' in models/user.rb 3). put a load 'models/profile.rb' in models/user.rb 4). class User
def before_initialization Profile.find(1) #just to load the Profile class, I know this looks stupid and desperate end
end
The only solution that works is
config.cache_classes = true #in development.rb
but as you know this is not acceptable.
Any ideas, what might be causing this bug and how I can fix it.
Regards, -daya