On 6 Nov 2008, at 16:39, Jonathan Rochkind wrote:
> > In my continued efforts to port my rails 1.x app to Rails 2.1.2, I > keep > running into what appear to be ActiveRecord bugs. > > I am using an :include on a :has_many definition: > > class Request < ActiveRecord::Base > has_many :service_types, :order=>'service_types.id ASC', > :include=>:service_response > [...] > > There's no reason this wouldn't be supported in Rails 2.1.2, is there? > It should work. :include was rewritten for rails 2.1 though. service_type has a belongs_to :service_response ? Fred > Worked fine in Rails 1.2.6. In Rails 2.1.2, I fetch in a Request > objects, and then I try to call some_request.service_types, and I > get an > exception. > > Anyone run into this? Any ideas? That :include is really useful to me > for efficiency. > > 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.each > > /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/ > association_preload.rb:74:in > `set_association_single_records' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/ > association_preload.rb:67:in > `each' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/ > association_preload.rb:67:in > `set_association_single_records' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/ > association_preload.rb:242:in > `preload_belongs_to_association' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/ > association_preload.rb:219:in > `each' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/ > association_preload.rb:219:in > `preload_belongs_to_association' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/ > association_preload.rb:40:in > `send' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/ > association_preload.rb:40:in > `preload_one_association' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/ > association_preload.rb:38:in > `each' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/ > association_preload.rb:38:in > `preload_one_association' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/ > association_preload.rb:17:in > `preload_associations' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/ > association_preload.rb:16:in > `preload_associations' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/ > association_preload.rb:16:in > `each' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/ > association_preload.rb:16:in > `preload_associations' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/ > base.rb:1347:in > `find_every' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/ > base.rb:540:in > `find' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/ > associations/association_collection.rb:47:in > `find' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/ > associations/association_collection.rb:308:in > `find_target' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/ > associations/association_collection.rb:262:in > `load_target' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/ > associations/association_proxy.rb:169:in > `method_missing' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/ > associations/association_collection.rb:279:in > `method_missing' > app/controllers/test_controller.rb:9:in `index' > -- > Posted via http://www.ruby-forum.com/. > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---