This forum has been of no help before, but I am nothing daunted.

I have a "people" table, mapping to a Person ActiveRecord class, which
has two subclasses, Principal and Secondary. There is a type column.

There is a "locations" table, mapping to Location. Location belongs_to
Principal. Principal has_many Locations. There is a principal_id column
in locations.

There is a LocationsController. It renders rhtml, which contains
something like

<%= @location.principal.full_name %>

... to which Rails complains "uninitialized constant
Location::Principal". locations_controller.rb does not refer to
Principal. The problem must come from the class information in the
relationship, or possibly in the STI type information.

If I change the belongs_to to:

belongs_to :principal, :class_name => "Person", :foreign_key =>
"principal_id"

it works, but this bothers me. It is not what I intend. Locations belong
to Principals, not to People in general.

The alternative, I think, is to have locations_controller.rb require
'person', but that gives me problems with reloading in development mode.

What should I do?

$ ruby --version
ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
$ rails --version
Rails 1.2.6
-- 
Posted via http://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 rubyonrails-talk@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-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to