Hi~

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.

Cheers-
-- Ezra Zygmuntowicz 
-- Lead Rails Evangelist
-- [EMAIL PROTECTED]
-- Engine Yard, Serious Rails Hosting
-- (866) 518-YARD (9273)



--~--~---------~--~----~------------~-------~--~----~
 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 [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-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to