On Oct 24, 11:07 am, "Michael .." <[email protected]>
wrote:
>
> I have the same Problem in find.
> Car.find(:all) returns two Records
> RallyCar.count
> Car.find(:all) returns four Records
>

This is  a known pecularity of STI - when you do a count for the
subclass it adds a type = "Car" condition. This obviously doesn't find
instances of RallyCar. Once the RallyCar class is loaded then
ActiveRecord is aware of its existance and will add type = "Car" or
type = "RallyCar" as the condition. It's a bit messy but in production
it should work fine (since all classes are loaded up front) or you can
also use require_dependency to force them to be loaded (ie at the
bottom of car.rb stick require_dependency 'rally_car')

Fred
> Can anyone help me.
>
> Thanks,
> Michael
> --
> Posted viahttp://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