I have two models: User and Manager. I use STI to inherit `Manager`
from `User` model.

app/models/user.rb

class User < ActiveRecord::Base
end

custom_lib/models/manager.rb

class Manager < User
end

I have added the models in the custom directory to load path as
follows:

config/environment.rb

config.autoload_path += File.join(RAILS_ROOT, "custom_lib", "models")


Every thing works as expected in development mode. In the production
mode I get the following error:

The single-table inheritance mechanism failed to locate the subclass:
Manager

For some reason rails is not loading the inherited classes.

To work around this issue I explicitly require the classes in an
initializer.

config/initializers/custom_models.rb

Dir[File.join(RAILS_ROOT, "custom_lib", "models", "*.rb")].each do |
file_name|
  require(File.join(File.dirname(file_name), File.basename(file_name,
".rb")))
end

I prefer to use autoload_path. I am wondering if anybody can explain
the reason for this behavior and any possible fix.

I am on Ruby 1.8.7, Rails 2.3.9, Ubuntu

-- 
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