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.
use require_dependency instead of require (and i would do this at the
top of the location model, not in the controller)
This was exactly what I needed. Thank you.
It’s too bad that Pickaxe (2nd ed) and Agile Web D. with Rails
(2nd ed) didn’t mention require_dependency. Can anyone recommend a
reference that would have included it?
use require_dependency instead of require (and i would do this at the
top of the location model, not in the controller)
This was exactly what I needed. Thank you.
It’s too bad that Pickaxe (2nd ed) and Agile Web D. with Rails
(2nd ed) didn’t mention require_dependency. Can anyone recommend a
reference that would have included it?
Well it’s a rails only thing so the Pickaxe would never cover it and
it’s also a bit of slightly hairy internal stuff. “Luke, Use the
source!”
Fred
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.