On 16 Jan 2009, at 20:44, Wes Gamble wrote:

>
> When I call Invoice.find_all_by_im_invoice_state("Paid").each the
> Invoice class is loaded.
>
> When the Invoice class is loaded, all of its class level association
> directives are executed.  When it hits the one that doesn't have a
> backing table, it fails.

So it's at the point where the class (not the data) is loaded that the  
problem occurs ? You might be in a tight spot then because it's going  
to be hard to remove the association before the class exists. I can  
think of two ways, neither of which is very nice.

define a new class Invoice < ActiveRecord::Base inside your fixture  
generation code. if you don't need any of Invoice's methods then  
you're fine with just this

Override ActiveRecord::Base.has_many to check if self is invoice and  
the association name is the bad one. if it is, do nothing. if not let  
the normal code run.

Fred


>
>
> So I need to be able to modify the Invoice class to remove the  
> offending
> association before the fixture load occurs.
>
> Wes
> -- 
> 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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to