Hi, I''ve got 3 classes : class Person < ActiveRecord:Base end class Man < Person end class Father < Man end When I call Man.all, I expect to have men and fathers, but I don''t. When I call Person.all, I have people, men and fathers... Do I have to redefine the find method of the Father''s class ??? Did I break some thing ? I''m pretty sure it worked before, but I really don''t know what I could have done to break it. I thought it could be an issue from Rails 2.1.2, but I got the same one with rails 2.1.1. Please help ! --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Nov 11, 3:40 pm, joserwan <joser...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I''ve got 3 classes : > > class Person < ActiveRecord:Base > end > > class Man < Person > end > > class Father < Man > end > > When I call Man.all, I expect to have men and fathers, but I don''t. > When I call Person.all, I have people, men and fathers... > > Do I have to redefine the find method of the Father''s class ??? > Did I break some thing ? I''m pretty sure it worked before, but I > really don''t know what I could have done to break it. > > I thought it could be an issue from Rails 2.1.2, but I got the same > one with rails 2.1.1. >This is a quirk of single table inheritance. If you use require_dependency to force all the subclasses of person to be loaded (eg at the bottom of person.rb) then it should work fine. Fred --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Works fine, thank you very much ! On 11 nov, 11:08, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Nov 11, 3:40 pm, joserwan <joser...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > Hi, > > > I''ve got 3 classes : > > > class Person < ActiveRecord:Base > > end > > > class Man < Person > > end > > > class Father < Man > > end > > > When I call Man.all, I expect to have men and fathers, but I don''t. > > When I call Person.all, I have people, men and fathers... > > > Do I have to redefine the find method of the Father''s class ??? > > Did I break some thing ? I''m pretty sure it worked before, but I > > really don''t know what I could have done to break it. > > > I thought it could be an issue from Rails 2.1.2, but I got the same > > one with rails 2.1.1. > > This is a quirk of single table inheritance. If you use > require_dependency to force all the subclasses of person to be loaded > (eg at the bottom of person.rb) then it should work fine. > > Fred--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
In facts, as Person.all gave me Men and Fathers, I had require_dependency ''father'' in the Man class. On 11 nov, 11:08, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Nov 11, 3:40 pm, joserwan <joser...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > Hi, > > > I''ve got 3 classes : > > > class Person < ActiveRecord:Base > > end > > > class Man < Person > > end > > > class Father < Man > > end > > > When I call Man.all, I expect to have men and fathers, but I don''t. > > When I call Person.all, I have people, men and fathers... > > > Do I have to redefine the find method of the Father''s class ??? > > Did I break some thing ? I''m pretty sure it worked before, but I > > really don''t know what I could have done to break it. > > > I thought it could be an issue from Rails 2.1.2, but I got the same > > one with rails 2.1.1. > > This is a quirk of single table inheritance. If you use > require_dependency to force all the subclasses of person to be loaded > (eg at the bottom of person.rb) then it should work fine. > > Fred--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---