Using rails 2.1.0
I have a Price class
class Price < ActiveRecord::Base ... end
which is referenced by Offering
class Offering < ActiveRecord::Base ... belongs_to :special_price, :class_name => 'Price', :foreign_key => "special_price_id" ... def price_str self.special_price.price_range_str end ... end
Unless 'price_str' is called the first time (i.e. on the first request after mongrel startup), I get
"D:/InstantRails/ruby186-26/lib/ruby/gems/1.8/gems/activerecord-2.1.0/ lib/active_record/attribute_methods.rb:256:in `method_missing' D:/InstantRails/ruby186-26/lib/ruby/gems/1.8/gems/activerecord-2.1.0/ lib/active_record/associations/association_proxy.rb:177:in `send' D:/InstantRails/ruby186-26/lib/ruby/gems/1.8/gems/activerecord-2.1.0/ lib/active_record/associations/association_proxy.rb:177:in `method_missing' app/models/care_offering.rb:41:in `care_price_str' app/views/carehome/new_offering.html.erb:11:in `_run_erb_47app47views47carehome47new_offering46html46erb' D:/InstantRails/ruby186-26/lib/ruby/gems/1.8/gems/activerecord-2.1.0/ lib/active_record/associations/association_collection.rb:274:in `method_missing_without_paginate' D:/InstantRails/ruby186-26/lib/ruby/gems/1.8/gems/activerecord-2.1.0/ lib/active_record/associations/association_proxy.rb:175:in `method_missing' D:/InstantRails/ruby186-26/lib/ruby/gems/1.8/gems/activerecord-2.1.0/ lib/active_record/associations/association_proxy.rb:175:in `each' D:/InstantRails/ruby186-26/lib/ruby/gems/1.8/gems/activerecord-2.1.0/ lib/active_record/associations/association_proxy.rb:175:in `send' D:/InstantRails/ruby186-26/lib/ruby/gems/1.8/gems/activerecord-2.1.0/ lib/active_record/associations/association_proxy.rb:175:in `method_missing' D:/InstantRails/ruby186-26/lib/ruby/gems/1.8/gems/activerecord-2.1.0/ lib/active_record/associations/association_collection.rb:274:in `method_missing_without_paginate' vendor/plugins/will_paginate/lib/will_paginate/finder.rb:164:in `method_missing' ..."
This does not happen with this model class class Offering2 < ActiveRecord::Base ... belongs_to :price ... def price_str self.price.price_range_str end end
THIS ONLY HAPPENS IN development, not in production mode. Is this just a "config.cache_classes = false" side effect? But why then does it only arise in the "indirect referencing scenario"?
Thanks in advance Clemens