If Users --> students // employee (single table inheritence), and they both belong to a Organization --> School // Work (single table inheritance), what is the proper way to write the association? I put the organization_id into the User class, and wrote the belongs to /has many in the respective subclasses, but when I call User.school, I get "nil", even though he has an organization_id = 1.
user.rb
class User < ActiveRecord::Base
attr_accessible :email, :name, :password, :organization_id, :type
end
student.rb
class Student < User
belongs_to :school
end
employee.rb
class Employee < User
belongs_to :company
end
organization.rb
class Organization < ActiveRecord::Base
attr_accessible :name
end
school.rb
class School < Organization
has_many :students
end
company.rb
class Company < Organization
has_many :employees
end