Find :include broken when upgrading to 2.2.2

Hi, I'm upgrading an old 1.2 application to latest 2.2 and I got an error which is certainly due to :include

@factures = Facture.find(:all, :include => [[:forfait => :vehicule] => :client], :conditions => ["MONTH(factures.date_emission) = ? AND YEAR(factures.date_emission) = ?", @mois, @annee], :order => 'clients.nom')

This code produces an error

You have a nil object when you didn't expect it! The error occurred while evaluating nil.macro

Does the :include option have changed its behaviour?

It did change slightly. I suspect that you originally got lucky: your include clause is

[[:forfait => :vehicule] => :client]

which ruby parses as [{[{:forfait=>:vehicule}]=>:client}]

which isn''t the type of structure that rails is expecting (but obviously happened to work in the past). It looks like what you should be saying is

{:forfait => {:vehicule => :client}}

Fred

Frederick Cheung wrote: