ユーザー --> 学生 // 従業員 (単一テーブル継承) で、両方とも組織 --> 学校 // 職場 (単一テーブル継承) に属している場合、関連付けを記述する適切な方法は何ですか? Organization_id を User クラスに入れ、それぞれのサブクラスに所属 /has をたくさん書いたのですが、User.school を呼び出すと、organization_id = 1 であるにもかかわらず、"nil" が返されます。
user.rb
class User < ActiveRecord::Base
attr_accessible :email, :name, :password, :organization_id, :type
end
学生.rb
class Student < User
belongs_to :school
end
従業員.rb
class Employee < User
belongs_to :company
end
組織.rb
class Organization < ActiveRecord::Base
attr_accessible :name
end
学校.rb
class School < Organization
has_many :students
end
company.rb
class Company < Organization
has_many :employees
end