以下の関連付けで2つのモデルを作成しました
class User < ActiveRecord::Base
has_many :roles, :dependent => :destroy
end
class Role < ActiveRecord::Base
belongs_to :user
end
class Student < Role
end
class Tutor < Role
end
ただし、新しい子ロールを作成すると、そのロールが属するモデルに関連付けられると思います。
そのような:
Tutor.create(:user_id => user_id)
私は期待します:
#some user @user
@user.roles
家庭教師を含む配列を持つこと。ただし、機能していないようです。私が間違っていることについて何か考えはありますか?