On 11/16/06, Ezra Zygmuntowicz <[EMAIL PROTECTED]> wrote: > > On Nov 16, 2006, at 11:49 AM, Nate Wiger wrote: > > I'm wondering if I've hit an edge rails bug. I'm using single table > > inheritance to map different types of components for a management app. > > The inheritance works fine, have the "type" column set, etc. > > > > The issue I'm hitting is that subclasses don't appear to be > > auto-loading missing constants (ie ServiceType to service_type.rb). > > This snippet will show the issue: > > > > ## component_type.rb (single-table inheritance) > > # if I uncomment these requires, it works: > > #require 'service_type' > > #require 'config_file' > > class ComponentType < ActiveRecord::Base > > Here you make an AR class ComponentType. > > > > def self.load_config_files(service_hint) > > service_type = ServiceType.find_by_service_type(service_hint) > > ConfigFile.find(:all) > > end > > end > > > > ## component_type/medius.rb > > class ComponentType::Medius < ComponentType > > end > > Here you are making a Medius class within a ComponentType class not > a class within a module like you might be thinking. > > > [EMAIL PROTECTED]:models]$ ls -lF > total 144K > drwxr-xr-x 3 nwiger sysadm 4.0K Nov 16 11:56 component_type/ > -rw-r--r-- 1 nwiger sysadm 1.8K Nov 16 12:19 component_type.rb > -rw-r--r-- 1 nwiger sysadm 92 Nov 15 16:43 service_type.rb > > > Here you have a component_type directory and a component_type class. > I think this is where your problem lies. If you either rename the > component_type directory or the component_type class then I think it > will resolve your conflict.
Nesting classes should work fine (I use it). I suspected that nesting a subclass in its superclass (A::B < A) is giving the grief, but a manufactured test case passes. Nate, could you set Dependencies.log_activity = true and include the ServiceType lookup error? jeremy --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@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-core?hl=en -~----------~----~----~----~------~----~------~--~---